Help - Search - Members - Calendar
Full Version: get text from mail message content
InsanelyMac Forum > Apple World > Mac Programming and Development > AppleScript and Automator
rikw
Hi

I'm trying to get the text (from content) out of selected mail messages and paste that text into a textEdit document using applescript.

My attempt gets stuck between the two apps I think?
CODE
tell application "Mail"
get selected
set para1 to "content"
end tell

tell application "TextEdit"
activate
make new document
open document window
end tell


My next plan was to set the new textEdit document text to para1, but this must transgress OO rules I haven't learned yet so does not compile / run.

Any help appreciated to move this on a stage or two please/
regards and tia
rik
A Nonny Moose
Without GUI scripting (which Apple destroyed with OS updates) this is rather hard with AppleScript.

This might be easier with Automator, since there are scripts to grab the mail message, but it will paste the entire message instead of just a part. Vexing indeed.
thePixeler
Is this what you need it to do?
CODE
tell application "Mail"
    set selectedMessages to selection
    if (count of selectedMessages) is equal to 0 then
        display alert "No Messages Selected" message "You must select a message first."
    else
        set theMessage to item 1 of selectedMessages
        set theContent to content of theMessage
        tell application "TextEdit"
            activate
            make new document
            tell the front document
                set paragraph 1 to theContent
            end tell
        end tell
    end if
end tell
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.