Goulasch
Goulasch

Reputation: 11

Applescript for mail rules

I have created a rule that messages move into a subfolder when they according to certain criteria. Additionally, I have saved in this rule an AppleScript that this mail copied subsequently into an DMS. It is working.

My problem is, that the name of the subfolder is (for now) not passed to the script. It contains only "INBOX":

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with theMessage in theMessages
                set nameAccount to name of mailbox of theMessage  # here is the problem !
                try
                    tell theMessage
                        — at this point get the data out of the mail
                    end tell
                    tell application id „DMS“
                        — here the  data will save to the dms
                    end tell
                end try
            end repeat
        end tell
        #            end try
        #        end tell
    end perform mail action with messages
end using terms from

How do I get the name of the destination folder from the active mail rule?

Upvotes: 1

Views: 340

Answers (1)

vadian
vadian

Reputation: 285079

Instead of the name get the whole mailbox object, it contains the actual reference in the folder hierarchy, to create a subfolder you need the reference anyway.

set theMailbox to mailbox of theMessage

PS: the tell application "Mail" block is not needed, the using terms block is sufficient to evaluate the terminology.

Upvotes: 1

Related Questions