Tuesday, September 17, 2019

#1 2019-06-06 08:26:39 am

rick_260
Member
Registered: 2012-06-28
Posts: 58

Mac Mail Download PDF Attachments Apple Script Help. Please.

Hi. I am using Mail 5.3 and need a script that will automatically download PDF attachments to a select folder on my network.

I have been searching the net and there a couple scripts available (most require the use of a Mail run to activate the script) but I have not been able to get them to function correctly or they have additional scripting which is not applicable.

The script is simple:

Every time Mail receives a message.

The script checks for PDF attachments.

If a PDF attachment exists it downloads the file to a folder on the network.

When I try to write it (or use known examples) they don't work...i am probably overthinking it sad

Thank you for your time and consideration

R260

Offline

 

#2 2019-06-06 12:32:15 pm

rick_260
Member
Registered: 2012-06-28
Posts: 58

Re: Mac Mail Download PDF Attachments Apple Script Help. Please.

this what i have so far. it does work but it doesn't take into account if the file all ready exist. so in other words if x.pdf exists and i send a new mail with change to x.pdf it does not over write.

i have a mail rule setup that says if ANY attachment type IS pdf run the following script

[code]
using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        set attachmentsFolder to "VOLUME:FOLDER:" 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)
                    end repeat
                end repeat
            end try
        end tell
    end perform mail action with messages
end using terms from
[/code]

i know this would be easier if i was running a newer version of mac mail but this is all i have sad

thank you R

Last edited by rick_260 (2019-06-06 12:36:04 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)