Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ViViDboarder

macrumors 68040
Original poster
Jun 25, 2008
3,447
2
USA
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?

Code:
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.