Use the dictionary in the Applescript editor to view mail properties, and you can quickly see the properties of any mail message. Here is a quick and dirty example of retrieving the contents of an email message.
tell application "Mail"
set the_messages to selection
repeat with this_message in the_messages
set mytext to content of this_message
end repeat
end tell
Modify the above script that copies the output to a temporary file and then passes that file to your Python script to act.
Clark source
share