I need to extract Recipient Email Addresses - is it impossible?

Hi I spent way too much time tonight trying to solve this problem, I hope someone brilliant can help.
I have a web store, and am CC'd on the receipts sent to my customers. So I have accumulated a large mailbox full of emails addressed to recipients other than myself.
I now need to extract those recipient email addresses into a .txt file.
Through my travels I discovered the simple script below. It's awesome except that it only works for sender addresses! When I try to tweak the code to extract recipient addresses it gives me an error.
Can anyone either modify this code, or point me in the right direction?
I just can't believe this should be so hard! (And it probably isn't except for me.)
Thanks.
tell application "Mail"
set selectionMessage to selection -- just select the first message in the folder
set thisMessage to item 1 of selectionMessage
set theseMessages to (every message in (mailbox of thisMessage))
repeat with eachMessage in theseMessages
set theFrom to (extract address from sender of eachMessage)
do shell script "echo " & quoted form of theFrom & return & " >> ~/documents/extracted.txt"
end repeat
end tell
------------------

Nice! Austin Kinsella1 your script works well but in some cases return this:
<Undisclosed-Recipient:;@studio.com>
I think this mail was sended with multiple addresses.
Try this one, I made some little changes.
Good Luck!
tell application "Mail"
set selectionMessage to selection -- just select the first message in the folder
set thisMessage to item 1 of selectionMessage
set theseMessages to (every message in (mailbox of thisMessage))
repeat with eachMessage in theseMessages
set headerMessage to all headers of eachMessage as string
set recipientMessage to {}
set start to false
set char_f to ""
set char_o to ""
set char_r to ""
set char__ to ""
set previousChar to ""
repeat with c in headerMessage
set c to c as string
if start is true then
if c is ">" then exit repeat
copy c to the end of recipientMessage
end if
if c is "<" " then set start to true
if char_r is "r" and previousChar is "r" and c is " " then set char__ to " "
if char_o is "o" and previousChar is "o" and c is "r" then set char_r to "r"
if char_f is "f" and previousChar is "f" and c is "o" then set char_o to "o"
if c is "f" then set char_f to "f"
set previousChar to c
end repeat
set recipientMessage to recipientMessage as text
do shell script "echo " & quoted form of recipientMessage & return & " >> ~/documents/recipients.txt"
end repeat
end tell

Similar Messages

  • Can I send iTunes gift to a recipient email address which is non apple account email (I.e. Comcast or Gmail) as long as the person has an apple account and device to redeem it for use.

    Can I send iTunes gift to a recipient email address which is non apple account email (I.e. Comcast or Gmail) as long as the person has an apple account and device to redeem it for use.

    Yes - gifts are sent to an email address not to the iTunes account, the email has a redemption code in it which the recipient then redeems. The recipient needs to be in the same country as yourself, he/she won't be able to redeem it if their account is in a different country's store.
    Redeeming a gift : Redeeming iTunes Gift Cards and content codes - Apple Support

  • Updated my AppleID account info.  Under password security shows an email address to be used to receive email with new password settings.  I need to update that email address, how do I do that?  Thanks!

    Updated my AppleID account info.  Under password security shows an email address to be used to receive email with new password settings.  I need to update that email address, how do I do that?  Thanks!

    Thanks for the help Niel.  I couldn't change the rescue email address (an address that no longer exists and is therefore useless) until I could correctly answer the security questions.  After numerous guesses, finally got them right.  Was then presented with the option to change the rescue email address. Guess the only other option was to have Apple Support make the change or reset my account info.  Have made note of the correct answers so this won't happen again.   Thanks for the fast response!!

  • Multiple recipient email addresses is not working  for xsl & PDF Attachment

    multiple recipient email addresses is not working properly when
    to list has some external email address and sending xls and PDF file as an attachment.
    Test Scenario:
    (A) Create mail target activity
    1)To email : use the multiple email id with some external domain (ex.
    [email protected] ,[email protected], [email protected])
    2)File attachment with .xls file and this file is sending to mail target as an inputstream(at runtime)
    3)Use all other valid parameter in activity.
    (B) Create a process flow File source to mail target
    Execute the process flow.
    Actual Result: Mail is received by every email account. Only external email account get correct file but other email account(as ([email protected])) attachment files
    displaying message
    �abc.xls� can not be accessed. The file may be read-only, Or you may be
    trying to access a read only location. Or, the server the document is stored on
    may not be responding.�
    When i trying to open xls and PDF file
    Expected Result:
    All type of file attachments should be supported with all valid email address
    (servers).
    Pls help me about this senario:
    What is problem in this case:
    I am sending code
    Session session =getSession(host,port,secure);
    session.setDebug(this._debug);
                   Transport trans = connect(host,port,session,userID,password);
                   Message message = new MimeMessage(session);
                   InternetAddress[] iAddr = null;
                   message.setFrom(new InternetAddress(fromName));
                   iAddr = InternetAddress.parse(toUserName, true);
                   message.setRecipients(Message.RecipientType.TO, iAddr);
                   message.setSubject(subject);
                   //BodyPart messageBodyPart = new MimeBodyPart();
                   Multipart multipart = new MimeMultipart();
                   MimeBodyPart messageBodyPart=null;
    if(dataLocation!=null && dataLocation.equalsIgnoreCase("ATTACHMENT")){
                        String tmpName=fileName;
                        if( inputstream != null)
                                  tmpName = makeAttachment(fileName,inputstream);
                        messageBodyPart = new MimeBodyPart();
                        DataSource source = new FileDataSource(tmpName);
                        messageBodyPart.setDataHandler(new DataHandler(source));
                        fileName = fileName.replace('\\', '/');
                        fileName = fileName.substring(fileName.lastIndexOf('/') + 1,
                                  fileName.length());
                        messageBodyPart.setFileName(fileName);
                        multipart.addBodyPart(messageBodyPart);

    First, when sending your message, the filename should be a simple
    filename, not containing any directory names.
    It sounds like your mail server might be doing some special
    processing of attachments, perhaps to prevent viruses.

  • Icloud still shows my old email address when I try to enter, asking me for a password I no longer have. I need to change my email address and password in ICLOUD but I can't find a way to do it. Any ideas? Thanks.

    icloud still shows my old email address when I try to enter, asking me for a password I no longer have. I need to change my email address and password in ICLOUD but I can't find a way to do it. Any ideas? Thanks.

    Logout (System Preferences>iCloud) then login with the new address and password.

  • Do we need to enter full email address in Incoming mail server settings on POP Account

    Do we need to enter full email address in Incoming mail server settings on POP Account or just the username? For example does it have to be [email protected] or only jim.nicholas works? How does it affect the way the emails are delivered between laptop (primary device) and ipad ???
    Please need help asap!!
    Thanks.

    For my POP account I have my full email address in the Address field but just my name (and not the '@...') in the User Name under Incoming Mail Server

  • I get a error when I send a Email. Recipient "email@address"  was rejected by server by sever

    I get a error when I send a Email. Recipient "email@address"  was rejected by server by sever

    I set up my email the way the phone and iPad do. Very simple. It works most the time, but I am usually on wifi also. I ran into problem saying email was rejected by server, and it put email in my outbox. I looked in here to see if anyone had a good solution, then realized after reading the post I never actually checked my servers. My actual servers were different than the defaults that were set up. Example : the default server was mail.roadrunner.com, but the actual should be pop-server.roadrunner.com, and same for the smpt-server.roadrunner.com. Based on the ISP, must have the correct servers. But I was always able to send while on wifi. That part I did not understand. But since I fixed the servers, I have not seen any problem sending on either the iPad or iPhone. If you have not found fix, hope this may help if still having problem

  • I need to change the email address in iCloud

    I need to change the email address in iCloud

    What do you mean? - the address you use for login or the @icloud.com email address created when you opened your iCloud account?
    LOGIN
    If your login is an @mac.com, @me.com or @icloud.com address you cannot change it. If it is a non-Apple email address you can change it, but please be careful to follow the procedure outlined here:
    Firstly, if you have 'Find My iPhone/iPad/iMac' enabled on any of your devices, turn it off.
    Create a new email address, for example  at Yahoo or Gmail, or anywhere convenient (or you can use an existing address as long as it has never been associated with an Apple ID).
    Go to http://appleid.apple.com and click 'Manage your Apple ID'. Sign in with the current ID.
    Where it says 'Apple ID and primary email address' and gives your current ID email address, click 'edit'.
    Enter your new address and click 'Save changes'.
    Now you will need to go to each of your devices and sign out in System Preferences (or Settings)>iCloud - 'Sign out' on a Mac, 'Delete this account' on an iOS device (this will not delete the account from the server).
    Then sign back in with your new ID. Your iCloud data will disappear from your devices when you sign out, but reappear when you sign back in.
    I re-iterate: before you start, turn off 'Find My Mac' (or whatever) or you will need the services of Support.
    EMAIL ADDRESS
    Once you have created an iCloud account and chosen an @icloud.com address to go with it you can't change the address (short of creating an entirely new account).
    However, all is not lost. You can add up to three 'email aliases' - these are additional addresses (not accounts) which deliver into the same inbox as the main account. (In fact it's a good idea to give out alias addresses, rather than the main address, because if they attract spam you can easily change them.)
    You should be aware before you start that once you've created an alias you cannot turn that address into a full iCloud account or move it to another account.
    More information on aliases here: http://help.apple.com/icloud/#mm6b1a490a

  • I need to change the email address that was installed in my phone the day I purchased it. How do I do this?

    Please help!!!!  I need to change the email address that was installed in my phone the day I purchased it. How do I do this?

    You'll have to do a hard reset, wiping all data in the process.
    Go to settings, tap on about then tap on reset your phone,

  • My Apple ID is not an email address.  My daugther just got an ipod touch and I'd like her to use my apple id as well.  It's stating it needs to be an email address?  What am I missing?

    My apple id is not an emal address.  My daughter just got an ipod touch and I'd like her to use the same apple id.  It is saying it needs to be an email address?  What am I missing?

    this is where I changed my appleID from being a name into being my email
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/

  • I get the following message when sending emails: The recipient "email address" was rejected by the server".  If I send the email to 3 people, one will be rejected and a different person will be rejected.  Any ideas?

    I get the following message when sending emails on my ipad:  The recipient "email address" was rejected by the server".  If I send the email to 3 people, one will be rejected.  If I send the same thing to the same 3 people a different one will be rejected.  Any ideas?

    Try a Reset [Hold the Home and Sleep/Wake buttons down together for 10 seconds or so (until the Apple logo appears) and then release. The screen will go blank and then power ON again in the normal way.] It is app and data safe!

  • Invalid Gift Unable to gift an item using iPhone 5s and iPad air, Error Message Invalid Gift.  You must enter a valid recipient email address.

    This has been going on for quite a while.  I am able to send/purchase gifts from my iMac however; when I attempt to purchase a gift on my iPhone 5s (iOS 7.0.4) or my iPad Air (iOS 7.0.4 ) i get the following error message:
    Invalid Gift
    You must enter a valid recipient email address.
    This happens no matter what email address I type in.   Once this message comes up you can only select "OK".   It never let's me finish my purchase.
    Any ideas?

    Hi there jphilyaw,
    You may find the information in the article below helpful.
    If you can't redeem your iTunes Gift Card or code
    http://support.apple.com/kb/HT6021
    -Griff W. 

  • Iphone 4S- getting "the recipient email address was rejected by the server", any one a suggestion?

    I have tried everything from reading different online suggestions (that is going into setting-mail, contacts, etc. and look at outgoing server and making sure setting is correct...) and still getting "the recipient email address was rejected by the server", I have tried resetting network and also hard reboot. Nothing seems to work and would greatly appreciate any new suggestion?
    Thank you.

    It could be a typo in the 'return adress' field, a setup problem by the sender of the email. Unless you can reply to the same email sometimes successfully. Have a look at the actual address you are trying to send to, often he errors are obvious.

  • I need to change my email address.  how do Ido this and keep everything?

    I need to change my email address forsecurity reasons.  Howdo I dothis without losiing everything from my old email address?

    The assigned name is the same as the one you chose when originally setting up the account, just with the @icloud.com suffix. It is exactly the same email account, not a new one.
    You cannot setup a new iCloud email account without setting up a new iCloud account under a different AppleID.
    Alternatively, you can setup email aliases: http://help.apple.com/icloud/#mm6b1a490a

  • I updated my email address on my itunes account, I verified the email I received.  Now when I try to sign on, i get a notice that I need to verify my email address, i click the link and it says email address already verified. I cant access my acct.

    I updated my email address on my itunes account, I verified the email I received.  Now when I try to sign on, i get a notice that I need to verify my email address, i click the link and it says email address already verified. I cant access my itunes account because it keeps saying my email isn't verified.  UGH!

    Hi ipad also keeps asking for the password to my apple account id, but when in itunes on the ipad it says his email account.
    he cannot update anything without it asking for my password to my account.
    Please help, thanks.

Maybe you are looking for

  • [svn:fx-trunk] 5558: Add hack to Grammar. jj to allow special component tags in spark and halo namespaces to resolve to special node in the parser .

    Revision: 5558 Author: [email protected] Date: 2009-03-25 14:50:18 -0700 (Wed, 25 Mar 2009) Log Message: Add hack to Grammar.jj to allow special component tags in spark and halo namespaces to resolve to special node in the parser. This will be re-add

  • Can't print highlighted text on pdf's in Preview

    I had printing problems with my office printer Canon IR series. the Canon update UFR II V 2.24 fixed this but brought a new problem. I can't print annotated pdf's correctly. Any highlighted text is covered with a full colour bar with no text visible

  • Where TF is the File menu?!

    Nice going with this new "improved" version with no menubar and few useful options under the Firefox "menu." Whose bright idea was this?

  • Sony Z1 Compact battery drop

    Hi All, got the Z1 Compact since jan. 2014 never had any problems regarding the battery now when the battery is below 50% it suddenly drops (not drains) to 1%.  and shutsdown. i noticed this problem since lollipop update  first screenshot show it jus

  • BAPI_PTMGRATTABS_MNGCREATION problem

    Dear All, I have to create Attendances in infotype 2002 in PA30 so I am using his function module. I am passing following import parameters . Emplyee Number ABS_ATT_TYPE HRABSATT_IN-from_date HRABSATT_IN-to_date. Once I execute function module I get