E-mail Files

Summary: Creates a new message in Mail with the selected files attached.
Requires: EagleFiler, Apple Mail
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2017-03-03

Description

Creates a new message in Mail with the selected files attached. The files’ notes are added to the body of the message.

Installation Instructions · Download in Compiled Format · Download in Text Format

Script

set _body to ""
set _includeNotes to true
tell application "EagleFiler"
    
tell browser window 1
        
set _records to selected records
        
set _files to {}
        
repeat with _record in _records
            
copy file of _record to end of _files
            
if _includeNotes then
                
set _body to _body & _record's note text & return
            
end if
        
end repeat
    
end tell
end tell
tell application "Mail"
    
make new outgoing message with properties {visible:true}
    
tell the result
        
set content to _body
        
try -- based on iPhoto script
            
set _signature to the message signature
            
name of _signature
            
set _useSignature to true
        
on error
            
set _useSignature to false
        
end try
        
repeat with _file in _files
            
make new attachment at end with properties {file name:_file's POSIX path}
        
end repeat
        
if _useSignature is true then
            
set message signature to _signature
        
end if
    
end tell
end tell