Hi
Is it possible to copy a mail message from Mail.app into a folder in Finder using AS.
I can currently drag the message from Mail to Finder manually but I would like to run a script to do this for me.
Any help would be appreciated.
Thanks
Tim
Hi
Is it possible to copy a mail message from Mail.app into a folder in Finder using AS.
I can currently drag the message from Mail to Finder manually but I would like to run a script to do this for me.
Any help would be appreciated.
Thanks
Tim
Mail.app does not provide us with the Save (some message) as native format (that is, as .eml file) command. Exists Save (some document) as native format, but every document of every message viewer returns missing value. Every document of every window returns missing value too. We will do it cunningly:
-- get name and source of chosen message
tell application "Mail"
set aMessage to item 1 of (get selection)
set richSource to (source of aMessage) as rich text
set theSubject to subject of aMessage
end tell
-- replace every ":" symbol in theSubject with "_"
set {ATID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set {itemList, AppleScript's text item delimiters} to {text items of theSubject, "_"}
set {theSubject, AppleScript's text item delimiters} to {itemList as text, ATID}
-- build destination file's HFS path
set outputFile to (((path to desktop folder) as text) & theSubject & ".eml")
-- write rich text to EML file
try
set fileReference to open for access file outputFile with write permission
set eof of fileReference to 0
write richSource to fileReference
close access fileReference
on error
try
close access file outputFile
end try
end try
Hi
Sorry for the late reply to this.
But forgot to thank you for your efforts. Have been using your awesome suggestion for a while now and it is invaluable.
Thanks again.