Extract email addresses from messages

G

Gil Ben-Horin

Does anyone know of a function or a script that I could apply to a mail
folder in order to extract the email addresses contained within the messages
in the folder?

Thanks
Gil
 
J

Jolly Roger

Does anyone know of a function or a script that I could apply to a mail
folder in order to extract the email addresses contained within the messages
in the folder?

Absolutely. AppleScript is made for this. : )

Paste this into /Applications/AppleScript/Script Editor, then save it
as a Script named "Extract Sender Addresses" into the
~/Documents/Microsoft User Data/Entourage Script Menu Items folder. To
use the script, select a group of messages in Entourage, then choose
Extract Sender Addresses from the Entourage script menu. The addresses
will be placed on the clipboard, ready to be pasted wherever you want.

-- begin script
-- sets the clipboard to a list of the senders of all selected messages

property pDelimiter : ", "
property pIncludeDisplayName : true

set senderList to {}
tell application "Microsoft Entourage"
set messageList to the current messages
repeat with nextMessage in messageList
set sName to nextMessage's sender's display name
set sAddress to nextMessage's sender's address
if pIncludeDisplayName then
set sPerson to sName & " <" & sAddress & ">"
else
set sPerson to sAddress
end if
if senderList does not contain sPerson then
set the end of senderList to sPerson
end if
end repeat
end tell

set saveDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to pDelimiter
set textList to senderList as text
set AppleScript's text item delimiters to saveDelims

set the clipboard to textList
-- end script


Some options:

If you'd rather have the list of addresses be delimited by a return
character, change this line like so:

property pDelimiter : return -- ", "

If you'd rather not include display names, change this line like so:

property pIncludeDisplayName : false -- true

Questions?
 
W

William Smith

Jolly Roger said:
Absolutely. AppleScript is made for this. : )

Paste this into /Applications/AppleScript/Script Editor, then save it
as a Script named "Extract Sender Addresses" into the
~/Documents/Microsoft User Data/Entourage Script Menu Items folder. To
use the script, select a group of messages in Entourage, then choose
Extract Sender Addresses from the Entourage script menu. The addresses
will be placed on the clipboard, ready to be pasted wherever you want.

Niiiice. This could also be useful for populating the Address Book and
then adding the new contacts to a group. Endless possibilities.

bill
 
J

Jolly Roger

Niiiice. This could also be useful for populating the Address Book and
then adding the new contacts to a group. Endless possibilities.

Believe it or not, I actually wrote an AppleScript a while back that
does just that. It looks for email from a list of preferred domains,
and any time it finds one, creates an address book entry for it with
certain fields (like the company name, address, et al) already
populated. Entourage's AppleScript support shines in this area. : )
 
D

Diane Ross

Believe it or not, I actually wrote an AppleScript a while back that
does just that. It looks for email from a list of preferred domains,
and any time it finds one, creates an address book entry for it with
certain fields (like the company name, address, et al) already
populated. Entourage's AppleScript support shines in this area. : )

Did you upload it to scriptbuilders? This is one that would be good for
listing on the Entourage Help Page favorite scripts page. I can make it
available for downloading from the Entourage Help Page if you don't want to
put it on scriptbuilders.

--
Diane Ross, Microsoft Mac MVP
Entourage Help Page
<http://www.entourage.mvps.org/>
Entourage Help Blog
<http://blog.entourage.mvps.org/>
 
J

Jolly Roger

Did you upload it to scriptbuilders? This is one that would be good for
listing on the Entourage Help Page favorite scripts page. I can make it
available for downloading from the Entourage Help Page if you don't want to
put it on scriptbuilders.

Unfortunately, I haven't ever made time to remove personal information
from the script and document it. Time is one thing I never seem to
have enough of! : /
 
G

Gil Ben-Horin

Yes, I'm sure it would be extremely popular - this script has saved me HOURS
of manual work
Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top