Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Searching a Mail message



On 2007-06-01, at 06:17:13, Jeffers wrote:

I'm after getting the content of a Mail message and want to search the content for an email address (email@hidden). Are there any helper methods in AppleScript in which to do this. I already tried parsing the message content but that didnt seem to work.

Here's a starter script. It'll only grab the first address from a paragraph. It works on my setup but not everyone's got Mail setup the same:

on PluckEmailAddresses()
tell application "Mail" to tell item 1 of (get selection)
set paras to every paragraph of (source as text)
set res to {}
repeat with i from 1 to count of paras
set p to item i of paras
if (p contains "mailto:" and p contains "<a href=""Apple-style-span" color="#0D407F">then
set s to offset of "mailto:" in p
set t to (characters s thru -1 of p) as text
set e to (offset of ">" in t) - 3
set end of res to (characters s thru (s + e) of p) as text
end if
end repeat
res
end tell
end PluckEmailAddresses
PluckEmailAddresses()

Philip Aker
email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Searching a Mail message (From: Jeffers <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.