clt60
clt60

Reputation: 63974

How to get Mail.app raw message in the Automator?

Need to get the raw message content from the OS X Mail.app a pass it to the next action.

Unfortunately - tested this - and doesn't works: :(

a

I don't want select the "content" of the message, but want pass the raw content (what is base64 encoded) to the next action.

So, probably will need some applescript action betwwen the "Get Selected Mail Messages" and "New document".

Haven't idea how to do this...

The "New TextEdit doc" is only for tests, the real action will be an perl script, what will read the raw message content from the stdin.

Upvotes: 1

Views: 2103

Answers (2)

adayzdone
adayzdone

Reputation: 11238

Try:

on run {input, parameters}
    set theSource to {}
    tell application "Mail"
        repeat with aMessage in input
            set end of theSource to aMessage's source & return
        end repeat
    end tell

    return theSource as text
end run

Upvotes: 3

Kaydell
Kaydell

Reputation: 474

Here is some code for an AppleScript action to be run after the action "Get Selected Mail Messages". It is to be placed within an action: "Run AppleScript"

-- This script accepts an input which is a list of message objects from Mail and returns their properties.
-- The properties returned are in the form of an AppleScript properties record.
on run {input, parameters}
    tell application "Mail"
        set output to {}
        repeat with thisMessage in input
            set output to output & (properties of thisMessage)
        end repeat
    end tell
    return output
end run

This script is progress I think, but its action returns a list of AppleScript records. You would want to pick and choose which fields that you wanted in the AppleScript and return all of the Mail messages as text for the next action, your Perl script to be able to parse plain text and not have to deal with AppleScript records.

You can use the AppleScript above to peek at the record keys and values and then write a AppleScript to actually be used in your finished workflow which selects just the fields that you want.

-- Kaydell
[email protected]
http://learnbymac.com

Upvotes: 2

Related Questions