The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Apple Mail Msg to OO3 - Add indented row Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
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.
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
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
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Postbox as alternative to Apple Mail Mixalis OmniFocus 1 for Mac 12 2011-01-06 01:26 PM
Inconsistent Clipping with Apple Mail nickgrossman OmniFocus 1 for Mac 1 2010-09-27 09:15 AM
Apple Mail to Omnifocus, with attachment chipjoyce Applying OmniFocus 1 2010-07-14 12:45 PM
clipping from Apple Mail dsolomon OmniFocus 1 for Mac 12 2007-11-25 07:04 AM
Apple Mail integration johnrover OmniFocus 1 for Mac 6 2007-06-10 09:13 AM


All times are GMT -8. The time now is 06:36 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.