The script below copies an email selected in Apple Mail and copies it into a new note at the end of the outline. There are a couple of options but the subject of the email is used as the name for the note e.g. “Email - Tuesday, 16 September 2014 15:50:11 - Subject of email”, the body of the email is copied into the note column of the row. If a column named either “Date” or “Start” and of type date then the date of the email is written there. Note the primary column should be renamed from ‘Topic’ to ‘Action’ and the date column is optional.
THE FORUM code quoting is a little off - just copy the rest of this post into applescript editor:
(* Script that imports the single selected email into OO. The script expects a column named "Action" and optionaly a column of type "date" named either "Start" or "Date". Please ensure that if a date column is used that it is set to the correct type i.e. type Date set from the inspector.
The code will work with either OO3 or OO4 depending how the tell statement is set, comment out the version you do not require.
The new note is added to the end of the outline.
The email subject is set as the main title of the entry while the body of the email is written to the note of the row. If there is no date column the title is datestamped.
If you wish to use different column names you will have to edit this script.
any questions email me smk at anvic dot net or post to this forum.
This script has been created with help from many other scripters - thanks!
Please feel free to use as you wish.
by Simon Knight
Sept 2014 v2
*)
-- First Copy the data in the email to variables
tell application "Mail"
-- get all the messages in the list with same subject
set tMessageList to selection
set tEmail to ""
set x to 1 -- Originally I grabbed all the emails in the selection in a repeat loop
--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
--display dialog "tSender is set to " & tSender --debug code
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 & "From: " & 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
--Tell statements for use with Omni Outliner
--tell front document of application "OmniOutliner3 Professional" --why does tell tDocument fail ?
--set tDocument to front document of application "OmniOutliner3 Professional"
--Tell statements for use with OO4
tell front document of application "OmniOutliner" --why does tell tDocument fail ?
set tDocument to front document of application "OmniOutliner"
-- check that script is applicable to the OO file should contain 2 columns
if title of every column does not contain {"Action"} then
display dialog "You need to have a column named 'Action' to use this script, you may also have an optional date type column named either 'Date' or 'Start', please either rename or add columns or edit the applescript. Simon K. " buttons "Cancel" default button 1
end if
-- Does cancel stop the script ? Yes
--If OO doc does not have a last section add one called E-Mails
try
set LastSection to last child of tDocument -- we only have one section at present named E-Mails
on error
tell tDocument --original
make new row at end of rows with properties {topic:"E-Mails"} -- this will become the email section
end tell
set LastSection to last child of tDocument
end try
-- add a new child row for the header of the email
--set LastRow to make new child at end of rows of LastSection with properties {topic:tSubject} -- this line works in oo3
set LastRow to make new row at end of rows of LastSection -- with properties {topic:tTitle}
-- if the outline contains either a date column or a start column then write the date here
set DateStampTitle to true
if title of every column contains {"Date"} then
set value of cell "Date" of LastRow to tDateSent
set DateStampTitle to false
end if
if title of every column contains {"Start"} then
set value of cell "Start" of LastRow to tDateSent
set DateStampTitle to false
end if
if DateStampTitle is true then
-- create the title text for the note
set tTitle to "Email - " & (tDateSent as string) & " - " & tSubject
else
set tTitle to "Email - " & tSubject
end if
set value of cell "Action" of LastRow to tTitle
--set value of cell "Date" of LastRow to tDateSent
--set value of cell "From" of LastRow to tSender
--set value of cell "Subject" of LastRow to tSubject
set note of last row to tEmail
-- Add a new child row to store the email body
-- set EmailBody to make new child at end of rows of LastRow with properties {topic:tEmail}
end tell