• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Searching a Mail message
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Searching a Mail message


  • Subject: Re: Searching a Mail message
  • From: Philip Aker <email@hidden>
  • Date: Fri, 1 Jun 2007 07:16:25 -0700

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:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

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

  • Prev by Date: Re: Searching a Mail message
  • Next by Date: Re: Determine whether spot color is RGB or CMYK in Illustrator CS2
  • Previous by thread: Re: Searching a Mail message
  • Next by thread: Re: Searching a Mail message
  • Index(es):
    • Date
    • Thread