PDA

View Full Version : Mail Rules Applescript




ViViDboarder
Oct 3, 2009, 02:07 PM
I'm trying to make a script to run from a rule that will download my attachments.

I'm a little stuck because I take the rule part out and tell it to just run on a selection and it works perfectly so it's got to be something to do with the perform_mail_action aspect.

It just runs the rule (I had it change the color of the item so I know it ran) but the script doesn't do anything. Ideas?


on perform_mail_action(theData)
set theOutputFolder to "Macintosh HD:Users:USERNAME:Dropbox:" as string
set theSelectedMessages to |SelectedMessages| of theData
set theRule to |Rule| of theData
display dialog theSelectedMessages
tell application "Mail"
repeat with theMessage from 1 to count theSelectedMessages
-- Process the current message
set theAttachments to theMessage's mail attachments
if theAttachments is not {} then
repeat with theAttachment in theAttachments
set theSavePath to theOutputFolder & theAttachment's name
try
save theAttachment in theSavePath
end try
end repeat
end if
end repeat
end tell
end perform_mail_action



electroshock
Oct 3, 2009, 02:11 PM
Something that might help:

http://forums.macrumors.com/showthread.php?t=791917

ViViDboarder
Oct 3, 2009, 02:13 PM
Something that might help:

http://forums.macrumors.com/showthread.php?t=791917

Doesn't. I already read that. The guy on the bottom posted something that doesn't get messages from a Mail Rule, so it doesn't really help.

Anyone know what's off with this?