Mail 5.3 Auto Save/Download Email PDF Attachments?

Discussion in 'Mac Basics and Help' started by ranger_rick, Jun 13, 2019 at 4:59 AM.

  1. ranger_rick macrumors newbie

    Joined:
    Monday
    #1
    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
     

Share This Page

0 June 13, 2019