Tuesday, September 21, 2021

#1 2018-01-25 08:11:25 am

timbaldwin
Member
Registered: 2006-08-14
Posts: 81

Copy Mail message into Finder

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


Tim


Filed under: mail, message, Finder

Offline

 

#2 2020-11-12 12:26:49 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2038

Re: Copy Mail message into Finder

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:

Applescript:


-- 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

Last edited by KniazidisR (2020-11-12 01:11:04 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2021-09-15 03:31:27 am

timbaldwin
Member
Registered: 2006-08-14
Posts: 81

Re: Copy Mail message into Finder

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.


Tim

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)