View Full Version : Applescript Mail Rule Help

Sep 22, 2010, 06:26 AM
Hi All,

Bit new here and my coding is ropey at best. Basically ive got some automated emails that appear in my inbox every 10 mins or so. They have the same subject but different contents. What I want to do is, when the emails come in to take the first line of it then send a new email with the first line as the subject.

So what ive done is to write an applescript which gets triggered on a subject line rule. The script is as follows:

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
set recipientAddress to "example@com.com"
tell application "Mail"
repeat with thisMessage in theMessages
set theText to paragraph 1 of content of theMessage
set theNewSubject to "!-- some text --!" & theText
set theNewMessage to make new outgoing message
tell theNewMessage
make new to recipient at end of to recipients with properties {address:recipientAddress}
set subjext to theNewSubject
set content to theText
end tell
delay 5
send theNewMessage
tell thisMessage
set replied to true
end tell
end repeat
end tell
end perform mail action with messages
end using terms from

Any help would be much appreciated. As i said earlier not even registering in the console and nothing seems to happen.


Sep 22, 2010, 09:01 PM
Take a look here:

The function name I believe needs to match what that shows. I use that same template just fine.

Sep 23, 2010, 03:23 AM
I put the script you linked into the rule and the rule is defiantly triggering. It doesnt then seem to be executing my script. I am going to try putting the script you linked into mine and see if it still triggers.


Sep 23, 2010, 04:27 AM
Okay after some testing it looks like paragraph 1 of content is no longer supported and is breaking the script - is there an alternative? This is really the most important part.