Extracting email addresses in Mail using AppleScript

I am using the following script to extract "from" email addresses within a specific mailbox in the Mail app:
tell application "Mail"
          set mlist to selection
          set cur_mbox to mailbox of item 1 of mlist
          repeat with msg in messages of cur_mbox
                    do shell script "echo " & quoted form of (sender of msg as rich text) & ">>~/.list.txt"
          end repeat
end tell
do shell script "cat ~/.list.txt |sort|uniq >~/desktop/list.txt; rm ~/.list.txt"
This is the format of the names and emails that I am getting in the .txt file:
"Person, Alex" <[email protected]>
"Person, Bob" <[email protected]>
"Person, Chris" <[email protected]>
I would like to ONLY extract the email address, NOT the name of the person attached, so I can copy and paste them into an Excel spreadsheet very easily.  Can anyone offer up an edit to this script so I only get the list of email addresses in the text file?
And if anyone wants to take it one step further... I am for sure going to have duplicate emails. Anyone have some script to eliminate doubles?
Thanks in advance!!

-

Similar Messages

  • Extract email addresses from Mail?

    A friend uses Mail on OS X 10.2 (Jaguar). He doesn't use Address Book. Instead, when he starts to type an address in Mail, Mail offers to complete it, often with several choices. His archive contains thousands of email addresses. My question: Is there a way to transfer the email addresses in Mail to Address Book without having to do each one manually?
    Mail comes up with choices of email address so quickly that it is hard to believe it scans the whole archive to find them. Does it have a database of some sort that it refers to? And can this database (if one exists) be read as a plain text file?
    Thanks!

    Hello, L.T.
    I don't know how this got messed up, but to manage the discussions you're subscribed to, log in. On the right side of the page, under "Welcome, L. T. Clarke", click on My Subscriptions. Deselect any discussions you don't want to follow.
    With respect to: "However I did post reference to D-LinkDBT-120 adapter that will pair with my bluetooth cell phone 6103", D-Link says "MAC OS X v.10.4.3 or higher required." ( DBT 120 )I don't know, myself, of a way around that requirement. Good luck, though.
    srb

  • A work flow to extract email address from mail

    Can anyone help me. I have a bunch of emails that contain text information including an email address. I want a Automator workflow that will extract the email addresses from the emails and then save them as a comma separated text file.

    Hi,
    Try this workflow:
    1) Get Selected Mail Items
    2) Run AppleScript
    In the "Run AppleScript", paste the following in:
    on run {input, parameters}
    set the output to {}
    repeat with i from 1 to count of the input
    set theMessage to item i of the input
    set theContent to ""
    tell application "Mail"
    set theContent to the content of theMessage
    end tell
    if theContent is not equal to "" then
    set output to (output & theContent)
    end if
    end repeat
    return output
    end run
    3) Run Shell Script
    In "Run Shell Script", select "/usr/bin/perl" in the shell popup and "to stdin" in the pass input popup. Then paste the following in:
    $input = join("", );
    @emails = ($input =~ /\b[A-Z0-9._%-]@[A-Z0-9.-]\.[A-Z]{2,4}\b/ig);
    while( @emails > 1 ) {
    print shift(@emails) . ", ";
    print @emails[0];
    4) New TextEdit Document
    If you select the mail messages that have the email information in them, then you can run the workflow and hopefully it does the right thing.
    Hope it helps!

  • Extract email addresses from email header - Sender (From) - Mail

    Hi!
    I would like to extract email addresses from email header from field "Sender (From)" and from email body in Mail at the same time.
    I saw only scripts how to extract from email body.
    I get emails asking for some informations about product and many people don't include their email address in the body, so I have to extract from email header as well.
    I would like to extract email addresses from whole email account, separate alphabeticaly, delete duplicates and save it (separated by comma) in text file.
    This I would use for sending massive email to all customers. 
    I'm on OSX 10.6.8.
    Do you have please somebody script for extracting email addresses in the way:
    1. select mail account
    2. run script
    3. save email addresses to txt file
    Thank you for help and advise!

    Hi Neville!
    Last time I was writing basic programs in Turbopascal in 1996.
    Maybe I'm doing something wrong...
    1. I switched off in Mail "Use Smart Addresses".
    2. I changed the path to my account in both commands:
    Command A.
    i=~/Library/Mail/[email protected]@pop.gmail.com # Input file path
    o=~/Desktop/ # Output file path
    n=`date "+%y%m%d%H%M%S"`-"addresses" # time stamped file name
    grep -rh From: $i | grep -o '[-a-zA-Z0-9.]*@.[^>]*' | awk '!seen[$0]++' > $o$n
    Command B.
    grep -rh From: ~/Library/Mail/[email protected]@pop.gmail.com | grep -o '[-a-zA-Z0-9.]*@.[^>]*' | awk '!seen[$0]++' > ~/Desktop/`date \"+%y%m%d%H%M%S\"`"
    3. I write commands in TERMINAL.
    result of Command A:
    List of couple emails same like before switching of "Use Smart Addresses"
    I answered it already above:
    It can extract to .txt file only email addresses from email header which includes after the name as well email address.
    Example:
    From: Neville Hillyer <[email protected]>
    If there is in header only the name without the email address then it's not extracted (email is visible after secondary click on the name)
    Example:
    From: Neville Hillyer
    I just checked that most of emails I have has in the emailheader only the name without the email address so I miss most of email addresses.
    Result of Command B:
    >
    And nothing going on...
    4. I tried the same in AppleScript editor
    Result of Command A:
    Syntax error. A unknown token can’t go after this identifier.
    I changed the path but I still get syntax errors
    (instead of i=~/Library... i put i= Users/muzaa/Library...)
    Result of Command B:
    Syntax error: A “from” can’t go after this identifier.
    grep -rh From: /Users/radimmuzikant/Library/Mail/[email protected]@pop.gmail.com | grep -o '[-a-zA-Z0-9.]*@.[^>]*' | awk '!seen[$0]++' > ~/Desktop/`date \"+%y%m%d%H%M%S\"`"

  • In Mail, is it possible to extract email addresses of senders from just one account inbox?

    In Mail, is it possible to extract email addresses of senders from just one account inbox?

    Click on the arrow next to the number of emails in the conversation. That'll show you each separate email. You can create a new mailbox (call it what you want) and drag that email out of the conversation into that mailbox.

  • TS3899 I am getting the message: Cannot Get Mail the "email address" is in use on another device. What is the remedy

    I am getting the message: Cannot Get Mail the "email address" is in use on another device. How do I fix this.

    Hello groriguez,
    The following article provides further information regarding the error you're experiencing.
    iOS: 'Mailbox Locked', account is in use on another device, or prompt to re-enter POP3 password
    http://support.apple.com/kb/TS2621
    Cheers,
    Allen

  • Is there a program to extract email addresses from a searchable pdf?

    Is there a program that will extract email addresses from a searchable pdf?
    I scanned a 75 page excel spreadsheet and used OCR to create a searchable pdf. I've verified that the OCR did work, the email address are searchable, but I need a way to extract them from the pdf so that I can add them to an email list database. There is other data in the spreadsheets that is not needed and it is making it impossible to just copy and paste. Does anybody know if there is a program available that works on the mac platform for this. Any help is greatly appreciated. Thanks!
    Nate

    Nate B- wrote:
    Is there a program that will extract email addresses from a searchable pdf?
    I scanned a 75 page excel spreadsheet and used OCR to create a searchable pdf. I've verified that the OCR did work, the email address are searchable, but I need a way to extract them from the pdf so that I can add them to an email list database. There is other data in the spreadsheets that is not needed and it is making it impossible to just copy and paste. Does anybody know if there is a program available that works on the mac platform for this. Any help is greatly appreciated. Thanks!
    Nate
    Nate,
    You might want to repost this in the Unix forum, or one of the scripts forums here:
    AppleScripts: http://discussions.apple.com/forum.jspa?forumID=724
    Unix: http://discussions.apple.com/forum.jspa?forumID=735
    Automator: http://discussions.apple.com/forum.jspa?forumID=1261

  • You can use the same email address that you used to set up the old Sync? , before bookmarks can return, if I registered success?

    for my old email address account( @qq.com)
    july 2014 I install new windows xp, but I can't log in before account 44*******@qq.com, its always give me enjoyful when I was easy open bookmark url from different computer.
    but there is no any notice or email to me firefox will have new sync system, if there, I could backup before bookmarks from 28 vision ( or some june's vision), but this big browser group is quiet, now, I can't log in again old account,
    achieve process:
    1st, normal account and right password, its show me unknown account.
    2nd, Password Reset, " An email has been sent to the requested account with further information. If you do not receive an email then please confirm you have entered the same email address used during account registration.", I couldn't receive any mail(or in spam) :(
    3rd, How to update to the new Firefox Sync ...
    "You can use the same email address that you used to set up the old Sync." , before bookmarks can return, if I registered success?
    I really feel disappointment with firefox( although used for many years), much text, but couldn't resolve clear simple path. answers more hidden link to read, I just use it explore internet, I am not technology engineer, don't care what so much b***t.
    thanks, back me old bookmarks only, thanks.

    Hi eddinchina,
    You should have no need to use the Old Sync account.
    As long as device or devices are Firefox 29 or later (They should all be Firefox 30 now) you should use the New Sync.
    You may use the same email address with both accounts.

  • Email address cannot be used for iMessage

    Just set up an icloud email address for my daughter. I want her to be able to use that icloud email address to send iMessages to me or her mother using our iPads and iPhones.
    I set up the icloud email address for her with no problem and am able to e-mail her with it and she is able to send emails back to me with it.
    Went into Settings>Messages>Add Another Email.  I typed in the icloud email address I set up for her and received the following error message:
    "This email address cannot be used for iMessage."
    I do not know why I received this error message.  The icloud email account was set up. 
    I also went into the Messages app on my phone and sent a iMessage to the iCloud e-mail account and received a response that the message was delivered and Read! 
    If anyone has dealt with this issue before, please let me know what you think.  Thank you!
    Joe

    So if I'm reading this right, you cannot assign multiple Apple IDs to iMessage on the same device?  You have to log out of the first in order to use the second?
    If this is true, does this work device to device?  In other words, if she has access to an iPad and an iPhone, could you allow the iPhone to message and FaceTime through my daugther's new icloud email while the iPhone is still assigned to her mother's e-mail?
    Or, is there a way to allow multiple apple IDs to iMessage and FaceTime on a sinle device WITHOUT having to disable one?
    Thanks for the previous fast response and the future help.
    Joe

  • Dynamic email address in MAIL adapter

    Hi ALL,
                 Is there a way of sending dynamic email addresses in mail adapter?
    Regards,
    XIer

    Xier,
    Yes. You can do it. Using Mail adapter option with Use MailPackage option.
    raj.

  • How do you set-up a hotmail email address in mail

    how do you set-up a hotmail email address in mail?
    I cant seem to add it. any ideas why it cant connect to the server? what server address should i be using?
    regards
    Brendon

    Hi bmuur,
    I also had the same problem.
    I clicked Microsoft Exchange and kept trying to add my hotmail account that way but it kept asking for a server address for it to work.
    If you go into Internet Accounts and instead of clicking Microsoft Exchange scroll down to the bottom of the list and click Add Other Account...
    It will ask what sort of account you want to be created and I selected Add Mail Account and clicked create.
    Enter your full name, hotmail email address and password.
    I then clicked create and it worked for me.
    Hopefully this solves your problem. 

  • Extracting email address from all mailbox in Exchange 2010

    Dear Team,
    I've requirement where i need to pull all the email addresses from all user mailbox accounts in exchange 2010. I need all email addresses to which we've send emails to/Communicated with and all received email addresses. Is there any script or Power Shell
    command to extract email addresses from all mailboxes in our domain(Send and Receive)
    Appreciate your quick help.
    Thanks,
    Mike Baig

    No it is not very clear but this is what I understood...
    "which we've send emails from our domain" - From address should be always primary smtp address.
    "which we've received emails to our domain" - This can be secondary smtp addresses as well.
    To get all email addresses (including secondary smtp addresses) you can use below...
    get-mailbox -ResultSize unlimited | Select displayname, primarysmtpaddress, @{Name="Email Addresses";Expression={[string]::join(', ', $_.EmailAddresses)}} | Export-Csv emailaddress.csv -NoTypeInformation
    Blog |
    Get Your Exchange Powershell Tip of the Day from here

  • Extract Email Addresses From A Webpage

    I'm trying to use automator to extract email addresses from a webpage. I'm a member of my local chamber and we can use other chamber email addresses we just have to copy and paste them from the chamber website. There are about 5,000 members so I would spend a good week doing this. I'm trying to get Automator to take care of it for me. So far I've used the action "Get Current Webpage From Safari" then "Get Text from Webpage" then "Filter Paragraphs" and I filter to only paragraphs with the @ sign would go through. Now I'm lost. All I really need is a list of the email addresses them selves and not all the junk like the company they work for and bla bla bla. All this stuff is also on the same line as the email address so it all comes through. Is there any way to filter specific text rather than an entire paragraph?

    in that page the emails are always at the end of the line. that simplifies the problem somewhat. add the following "run shell script" action to your workflow right after the action that filters out paragraphs that contain emails
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    for f in "$@"
    do
    echo "$f"|awk '{print $NF}'
    done</pre>
    pass the input to this action as arguments.
    Message was edited by: V.K.

  • HT201407 hi..I cant activate my Iphone 5. I bought this from someone who cant remember her apple password and even the email address that she used to set up the account.What am I gonna do now....How can I activate my Iphone. what are my options...pls help

    hi..I cant activate my Iphone 5. I bought this from someone who cant remember her apple password and even the email address that she used to set up the account.What am I gonna do now....How can I activate my Iphone. what are my options...pls help me.thank you

    Activation Lock in iOS 7  >  http://support.apple.com/kb/HT5818
    hannibalfromlemery wrote:
    .I cant activate my Iphone 5. I bought this from someone
    The Apple ID and Password that was Originally used to Activate the iDevice is required.
    If you cannot get this information from the seller
    Removing a device from a previous owner’s account
    You need to return the Device for a refund, as you will not be able to re-activate it.

  • FaceTime: I have a iPad, iPhone, iMac all on the same apple Id/account. Without changing id/email address can I use FaceTime between any 2 of my devices? It works from iPad to iPhone but not the other way??? I would like talk/see my kids if am away

    FaceTime: I have a iPad, iPhone, iMac all on the same apple Id/account. Without changing id/email address can I use FaceTime between any 2 of my devices? It works from iPad to iPhone but not the other way??? I would like talk/see my kids if am away.
    Hope you can help.
    I have added a new email address but kept my Id, but I get busy when trying from iPhone to iPad as they are clashing. Like find my iPhone app hence trying to keep them all on one account

    IOS: using facetime http://support.apple.com/kb/ht4319
    using an ipad will use the email address since you can't make a phone call.  see the link.
    Your basically calling/emailing yourself that's why your getting a busy signal.

Maybe you are looking for