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

ranger_rick

macrumors newbie
Original poster
Jun 10, 2019
2
0
hi everyone. i am using a 2006 mac pro as a server (10.7.5) and i need a way to automatically download email PDF attachments to a specific folder on a network.

generally this is doable via a mail rule and applescript combo. (or depending on the version of Mail you are using you can set it up so that it always downloads attachments and you spec the download folder)

i do have a working script that is functioning with a rule in Mail 9.3. (script posted below) but when i try to deploy the same script it only functions when I apply it in Mail 5.3 and not on new email downloads . Obviously there are differences in the two Mail versions but i should be able to get it to function the same.

Rule in 9.3: "If ANY of the following conditions are met ATTACHMENT TYPE is PDF perform the following actions RUN APPLESCRIPT "Simple Upload"

Rule in 5.3 "If ANY of the following conditions are met ATTACHMENT NAME CONTAINS PDF perform the following actions RUN APPLESCRIPT "Simple Upload"

is there away around rule issue? or a different way of handling mail PDF attachments that would save them from emails automatically?

here is the script i am using (i need to add an "if" statement so it only downloads PDF's)

Code:
using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        set attachmentsFolder to "xxxx:yyyy:" as rich text
        tell application "Mail"
            set selectedMessages to theMessages
            try
                repeat with theMessage in selectedMessages
                    repeat with theAttachment in theMessage's mail attachments
                        set originalName to name of theAttachment
                        set savePath to attachmentsFolder & originalName
                        save theAttachment in file (savePath) with replacing
                    end repeat
                end repeat
            end try
        end tell
    end perform mail action with messages
end using terms from

thank you for your time and consideration RR
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.