The following script is designed to parse a mail message, save it as a tab delimited text file which I can then import into daylite.
The problems are it saves the file on my desktop and it replaces any earlier versions with the same name. So if I ran the script three times in one day only the last time would be in the file. I am using mail convert to convert the file to the proper format. I have a second drive named hitachi which I would like to save the files in a folder on.
below is the applescript
Convert Mail to Tab Text
set mycounter to 0
set myText to ""
(*
You can uncomment out the appropriate line depending on whether you wish to use TextEdit or BBedit. Only one line should be uncommented. TextEdit is the default.
*)
--set myTextEditor to "BBEdit"
set myTextEditor to "TextEdit"
tell application "Finder"
if myTextEditor is "TextEdit" then
set myhomename to name of home as text
set mydrive to startup disk
set filename to name of startup disk & ":Users:" & myhomename & ":desktop:Email Contents" as string
else
set myhomename to name of home as text
set mydrive to startup disk
set filename to name of startup disk & ":Users:" & myhomename & ":desktop:Email Contents" as string
end if
end tell
tell application "Mail"
set mymessages to the selection as list
repeat with mymessage in mymessages
set myText to myText & the source of mymessage
end repeat
end tell
if myTextEditor is "TextEdit" then
-- Send messages to TextEdit to save
tell application "TextEdit"
activate
make new document at the beginning of documents with properties {text:myText}
set modified of front document to yes
save front document in filename
quit
end tell
else
-- Send messages to BBEdit to Save
tell application "BBEdit"
activate
-- create the file
make new text window with properties {name:filename, contents:myText}
-- save the file in the folder created above
save text window 1 to filename
close text window 1
-- exit BBEdit
quit
end tell
end if
tell application "Mail Convert"
-- launch Mail Convert
activate
-- process the file created by BBEdit
Process filename
-- exit Mail Convert
Quit
end tell