Hi,
I am experimenting with an Applescript that will copy an email message with header information into an Outline. The Outline must have at least two columns : one named "Subject" the second "Date". The date column should be formatted as a ling date. The script will run and both copy the email to the clipboard and into the outline.
The problem is at the end : I wish to add the body of the email (tEmail) to a row that is a child of the row above. I have tried all sorts of syntax but failed each time. I know it must be simple but .......
Thanks in anticipation
Simon
I am experimenting with an Applescript that will copy an email message with header information into an Outline. The Outline must have at least two columns : one named "Subject" the second "Date". The date column should be formatted as a ling date. The script will run and both copy the email to the clipboard and into the outline.
Code:
tell application "Mail" -- get all the messages in the list with same subject set tMessageList to selection --set theMessageID to the message id of item 1 of tMessage --set thesubject to the subject of item 1 of tMessage --set theheaders to the all headers of item 1 of tMessage --set thehead to the headers of item 1 of the selection set tEmail to "" -- loop thorough all the messages in the list or perhaps not --repeat with x from 1 to (count tMessageList) -- comment out the repeat loop and set x to 1 to just copy one message set x to 1 --From: set tSender to the sender of (item x) of tMessageList --Subject: set tSubject to the subject of (item x) of tMessageList --Date: set tDateSent to the date sent of (item x) of tMessageList --To: set tRecipients to the recipients of (item x) of tMessageList set tAddresseeList to "" repeat with n from 1 to (count tRecipients) set tAddressee to (item n) of tRecipients set tAddresseeList to tAddresseeList & address of tAddressee & return end repeat --list of recipients -- Message Body set tContent to the content of (item x) of tMessageList -- end the loop through message list -- build the data set tEmail to tEmail & "XXFrom: " & tSender & return set tEmail to tEmail & "Subject: " & tSubject & return set tEmail to tEmail & "Date: " & tDateSent & return set tEmail to tEmail & "To: " & tAddresseeList & return set tEmail to tEmail & tContent & return end tell -- Apple Mail set original to front document of application "OmniOutliner Professional" tell front document of application "OmniOutliner Professional" -- Trap for script being run in a brand new blank documnt -- Later perhaps -- check that script is applicable to the OO file should contain 4 columns if title of every column does not contain {"Subject", "Date"} then display dialog "You need two columns named 'Subject,Date,' to use this script " buttons "Cancel" default button 1 end if -- A brand new document may not have any rows so trap for this condition -- create a blank row if the document has no rows (i.e brand new document) - unlikely if not (exists (last row of original)) then tell original make new row at end of rows end tell end if set tRow to the last row of original set value of cell "Subject" of tRow to tSubject set value of cell "Date" of tRow to tDateSent --set LastSection to last child of original -- --add a new row as error is thrown when there are no rows in section at level --set MessageData to make new child at end of tRow of LastSection --with properties {topic:dateString} -- add new row for data --make new child of tRow --whose level = 2 set DataRow to make new child at end of rows of original --set tRow to the last row of original set value of cell "Subject" of DataRow to tEmail end tell -- OO3
Thanks in anticipation
Simon