1

I'm trying to create an applescript that will take messages that match a certain filter YYYY), and forward them to a specific notebook in Evernote (XXXX), with the attachment intact. So far, I've gotten this script to handle the forwarding to a Evernote notebook thing, but I can't seem to get it to deal with attachments correctly.

How do I attach all of the attachments in the emails found by the filter (which would ideally run when messages are received) to the new forwarded email?

using terms from application "Mail"
    on perform mail action with messages selection for rule YYYY
        tell application "Mail"
            set theSelection to selection
            set thesubject to subject of item 1 of theSelection
            set theAttachments to every attachment of content of theSelection
            set theForwardedMessage to forward (item 1 of theSelection) with opening window

            tell theForwardedMessage
                make new to recipient at end of to recipients with properties {address:"ZZZZ"}

                set subject to subject of item 1 of theSelection & " @XXXX"
                repeat with a from 1 to length of theAttachments
                    log "message_attachment =" & a
                    make new attacment with properties {filename:a} at after last paragraph
                end repeat
                send
            end tell
        end tell
    end perform mail action with messages
end using terms from

You must log in to answer this question.

Browse other questions tagged .