• 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: Sending from Mail
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending from Mail


  • Subject: Re: Sending from Mail
  • From: Philip Aker <email@hidden>
  • Date: Sun, 20 Sep 2009 02:26:44 -0700

On 2009-09-19, at 11:04:59, LuKreme wrote:

OK, after looking at the sample scripts I came up with the following:

property SendAddress : "email@hidden"
property theSubject : "Automated Warning"
property theBody : "Alert: "
property theFrom : "email@hidden"

tell application "Mail"
set newMessage to make new outgoing message
tell newMessage
set subject to theSubject
set content to theBody
set visible to true
set sender to theFrom
make new to recipient with properties {address:SendAddress}
end tell
send newMessage
end tell

Nifty, the message is created. However, I want to get something out of the subject of the message I am going to be replying to.

For example, let's say the message comes from email@hidden with a subject of "Automated Warning: <process> not responding" where <process> can be any of a number of things. The text around <process> is predictable.

I want to fire my AppleScript in reply to that message (easy enough with the Rules in Mail.app) and send an SMS that says "Alert: Process"

How do I get that word out of the original subject?

Here I'm getting the subject of every post in a nested mailbox whose sender is "email@hidden".

tell application "Mail"
set mlst to (get subject of every message of mailbox "x" of mailbox "y" whose sender contains "email@hidden")
end tell

So I think you can get the subject of a specific message easily and then test to see if it contains a certain word.


What if the word I want is in the body, still surrounded by predictable text?

That is sometimes difficult depending on how the sender has formatted the message. I think the best way is to grab the 'source' property of a message but be aware this is the raw text (including the headers, HTML cruft, etc.).


Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.

 _______________________________________________
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

  • Follow-Ups:
    • Re: Sending from Mail
      • From: LuKreme <email@hidden>
    • Re: Sending from Mail
      • From: Philip Aker <email@hidden>
References: 
 >Sending from Mail (From: LuKreme <email@hidden>)

  • Prev by Date: Re: Snow Leopard and (old) AppleScript applications
  • Next by Date: Re: Sending from Mail
  • Previous by thread: Sending from Mail
  • Next by thread: Re: Sending from Mail
  • Index(es):
    • Date
    • Thread