Re: How to extract the email address in a the message body
Re: How to extract the email address in a the message body
- Subject: Re: How to extract the email address in a the message body
- From: Allen Watson <email@hidden>
- Date: Mon, 08 Nov 2004 09:14:23 -0800
On 11/7/04 11:08 PM, "Leon Chen" <email@hidden> wrote:
> Does anyone know how I could extract the email addresses within in the
> message body in the Mail.app? I was trying to write a script to filter
> a mail folder which contains all the bounced back mail messages.
I wrote a script to do exactly that, but for Microsoft Entourage. You should
be able to adapt it for mail.app. It requires the free Satimage scripting
addition, which contains a "find text" command that accepts regular
expressions. <http://www.satimage.fr/software/downloads/Satimage259.sit>
set delims to "[" & tab & return & ".,;:(){}<> ]"
tell application "Microsoft Entourage"
set od to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set theMsgs to current messages
set goodones to {}
set excludes to {a list of addresses you don't want to harvest, e.g.,
your own}
repeat with theMsg in theMsgs
set c to the content of theMsg
if c contains "@" then
set addrs to (find text (delims &
"*[a-zA-Z0-9._\\-]+@[a-zA-Z0-9._\\-]+" & delims & "*") in c with regexp, all
occurrences and string result)
end if
repeat with anItem in addrs
set temp to anItem
repeat while character 1 of temp is in delims
set temp to text 2 thru -1 of temp
end repeat
repeat while last character of temp is in delims
set temp to text 1 thru -2 of temp
end repeat
repeat while temp begins with " "
set temp to text 2 thru -1 of temp
end repeat
if temp is not in excludes then
--display dialog "\"" & temp & "\""
if temp does not contain "daemon" and temp is not in
excludes then
copy temp to end of excludes
copy temp & return to end of goodones
end if
end if
end repeat
end repeat
end tell
set AppleScript's text item delimiters to {""}
tell application "Finder" to set f to (folder "Documents" of home) as string
set fref to open for access file (f & "Bounced list") with write permission
set newList to goodones as string
write newList to fref starting at 0
close access fref
display dialog "List saved in " & f & "Bounced List" giving up after 3
--
<email@hidden>
Scripts for OE and Entourage: <http://allenwatson.thinkaccess.net/Scripts/>
Entourage questions: <http://www.entourage.mvps.org/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden