• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Saving Mail Message as source
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving Mail Message as source


  • Subject: Re: Saving Mail Message as source
  • From: Luther Fuller <email@hidden>
  • Date: Wed, 27 May 2009 12:56:36 -0500

On May 27, 2009, at 8:32 AM, Reza Farhad wrote:
Can anybody help me with the script in Mail to save a message as source.

I would like to use the AppleScript command "save ___ in ___ as ___ " to save a message into particular location.


I tried to get Mail's "save ___ in ___ as ___ " command to work, but it seems not to want to cooperate. If you simply want a copy of the message as an .emlx file then something like this will work ...

tell application "Mail"
activate
set frontViewer to message viewer 1
set selected mailboxes of frontViewer to {trash mailbox}
set msg to first message of frontViewer
set selected messages of frontViewer to {msg} -- for example
--
-- I tried to get Mail's 'save' command to work here
-- but I just couldn't make it happen
--
set msgID to (id of msg) as text
end tell
set mailFolder to (((path to library folder from user domain) as text) & "Mail:") as alias
tell application "Finder"
try
set msgAlias to some file of entire contents of mailFolder whose name starts with msgID
reveal msgAlias -- for display only, you don't need this
on error errText number errNr
"Error = " & errNr & return & errText
display dialog the result
end try
-- Now that you have an alias to the file of the message, you can command
-- the Finder to save it wherever you like. The saved file will be an .emlx file.
-- This is equivalent to using Mail's File/Save as menu with Raw Message Source selected.
end tell


'entire contents' may be slow. If this is a problem you can use Mail's 'container of' command to reconstruct the exact path to the folder in / Library/Mail. Hope this helps.


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Saving Mail Message as source
      • From: Reza Farhad <email@hidden>
References: 
 >Saving Mail Message as source (From: Reza Farhad <email@hidden>)

  • Prev by Date: address book data without opening app?
  • Next by Date: Re: Saving Mail Message as source
  • Previous by thread: Re: Saving Mail Message as source
  • Next by thread: Re: Saving Mail Message as source
  • Index(es):
    • Date
    • Thread