Mail Rules Applescript

Discussion in 'Mac Programming' started by ViViDboarder, Oct 3, 2009.

  1. macrumors 68040

    ViViDboarder

    Joined:
    Jun 25, 2008
    Location:
    USA
    #1
    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
    
     
  2. macrumors 6502a

    electroshock

    Joined:
    Sep 7, 2009
  3. thread starter macrumors 68040

    ViViDboarder

    Joined:
    Jun 25, 2008
    Location:
    USA
    #3
    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?
     

Share This Page