Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send mail with attachment and signature via AppleScript in OS X
tell application "Mail"
set theSubject to "Subject" -- the subject
set theContent to "Content" -- the content
set theAddress to "xxx@163.com" -- the receiver
set theSignatureName to "signature_name"-- the signature name
set theAttachmentFile to "Macintosh HD:Users:moligaloo:Downloads:attachment.pdf" -- the attachment path
set msg to make new outgoing message with properties {subject: theSubject, content: theContent, visible:true}
tell msg to make new to recipient at end of every to recipient with properties {address:theAddress}
tell msg to make new attachment with properties {file name:theAttachmentFile as alias}
set message signature of msg to signature theSignatureName
send msg
end tell
@Paul-Bostwck

This comment has been minimized.

Copy link

commented Jan 23, 2016

This works for me except the signature part... I am experimenting on a fix but having trouble

@padraigohoulihan

This comment has been minimized.

Copy link

commented Jun 24, 2016

Likewise all works for me excluding the signature, which becomes active and then returns to none..

@Quantizen

This comment has been minimized.

Copy link

commented Jun 30, 2016

delay 1 is needed to finish attaching the file. BTW, signature does not work for me also.

@adammoisa

This comment has been minimized.

Copy link

commented May 16, 2017

@Quantizen where does delay 1 go?

@adammoisa

This comment has been minimized.

Copy link

commented May 16, 2017

@Quantizen nevermind, I got it! Just put it before the send command and worked like a charm. Been searching and searching for that!

@buckmanhands

This comment has been minimized.

Copy link

commented Feb 8, 2019

Definitely needed the delay command. I used a delay 5 just in case things are going slow. Put it right before send command. I skipped using the signature and added it to the content itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.