dams net
dams net

Reputation: 301

AppleScript sending emails with attachment between contents

I'd like to send and email with apple script to do like this :

hi,
here is the attachment file
[The attachment.pdf]

As you can see, it is a good attachment
Thanks
Bye

I know how to use applescript to send an email with attachment at the end of the message, but not between 2 sentences.

I tried something like this, but it doesn't work :

set _attachment to "Macintosh HD:Users:usr:Desktop:Form.pdf"

set msg to make new outgoing message with properties {visible:true, subject:"Here it is", content: "hi,
here is the attachment file"}

tell msg to make new attachment with properties {file name:_attachment as alias}

tell msg to add "As you can see, it is a good attachment
Thanks
Bye" as content

Thanks you all for your support.

Dam

Upvotes: 0

Views: 641

Answers (1)

vadian
vadian

Reputation: 285079

Assuming we are talking about Apple Mail, you can specify the location of the attachment in the content of the message.

The text of body is passed instantly and the attachment is inserted afterwards.

set _attachment to (path to desktop as text) & "Form.pdf"

tell application "Mail"
    set msg to make new outgoing message with properties {visible:true, subject:"Here it is", content:"hi,
here is the attachment file



As you can see, it is a good attachment
Thanks
Bye"}

    tell content of msg to make new attachment with properties {file name:_attachment as alias} at after third paragraph
end tell

Upvotes: 1

Related Questions