Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript to Send Mail in El Capitan

Prior to OS X 10.11, I could tell Mail to set theMessage to makenewoutgoing messagewith properties {...}


However, this no longer seems to work in 10.11 as it doesn't recognize the class "outgoing message." Does anyone know of a new way to accomplish this?

Posted on Oct 6, 2015 11:54 PM

Reply
10 replies

Oct 8, 2015 10:09 AM in response to Camelot

I am also having an issue with an Applescript to forward an email in Mail since upgrading to El Capitan. The new message opens but the address and subject remain blank and rest of the script does not run (send and archive). It worked fine prior to El Capitan. Any thoughts are very much appreciated.


set theForwardedMessage to forward (item 1 of theSelection) with opening window


tell theForwardedMessage

make new to recipient at end of to recipients with properties {address:theAddress}

set subject to thesubject


end tell



Note that I set the variables (theAddress and theSubject) in the script prior to these lines.

Oct 19, 2015 7:05 PM in response to slotguru

I have a similar problem that started once I upgraded to El Capitan.

set theNewMessage1 to makenewoutgoing messagewith properties {visible:false, subject:to_subject, sender:my_sender}

tell theNewMessage1

makenewto recipientat end of to recipientswith properties {address:to_email}

set html content to to_content

send

end tell

There's been a long-standing "bug" where Mail wouldn't properly render html content on the screen unless the mail message had "visible:false." But this uses "visible:false" so this is not a problem.

After my upgrade to El Capitan, when I use the above snippet it sends -- but the message is empty message. It's as if the content never got set. (If I use "set content to to_content" it will work -- just not render HTML; and, all the variables are properly set and there's no error reported). Any help appreciated.

Oct 23, 2015 8:23 AM in response to Daniel Hunter1

Hi,

before I upgraded to El Capitan, my script works fine. After last upgrades, new message was create right but without attachment.
The only way to send email with attachment is to put DISPLAYMAIL true (message is ok, but user must press SEND to send a new mail)
Anyone find a solution? (EXCEL MACRO)



Function MailFromMacWithMail(bodycontent As String, mailsubject As String, _

toaddress As String, ccaddress As String, bccaddress As String, _

attachment As String, displaymail As Boolean)

Dim scriptToRun As String



scriptToRun = scriptToRun & "tell application " & _

Chr(34) & "Mail" & Chr(34) & Chr(13)



scriptToRun = scriptToRun & _

"set newmail to make new outgoing message with properties " & _

"{content:""" & bodycontent & """, subject:""" & _

mailsubject & """ , visible:true}" & Chr(13)



scriptToRun = scriptToRun & "tell NewMail" & Chr(13)



If toaddress <> "" Then scriptToRun = scriptToRun & _

"make new to recipient at end of to recipients with properties " & _

"{address:""" & toaddress & """}" & Chr(13)



If ccaddress <> "" Then scriptToRun = scriptToRun & _

"make new cc recipient at end of cc recipients with properties " & _

"{address:""" & ccaddress & """}" & Chr(13)



If bccaddress <> "" Then scriptToRun = scriptToRun & _

"make new bcc recipient at end of bcc recipients with properties " & _

"{address:""" & bccaddress & """}" & Chr(13)




If attachment <> "" Then

scriptToRun = scriptToRun & "tell content" & Chr(13)

scriptToRun = scriptToRun & "make new attachment with properties " & _

"{file name:""" & attachment & """ as alias} " & "at after the last paragraph" & Chr(13)

scriptToRun = scriptToRun & "end tell" & Chr(13)

End If

If displaymail = False Then

' scriptToRun = scriptToRun & "send" & Chr(13) LINE COMMENTED DUE TO PROBLEM

End If

scriptToRun = scriptToRun & "end tell" & Chr(13)

scriptToRun = scriptToRun & "end tell"

If Len(toaddress) + Len(ccaddress) + Len(bccaddress) = 0 Or mailsubject = "" Then

MsgBox "Destinatario inesistente, errato o azione Email cancellata"

Exit Function

Else

On Error Resume Next

MacScript (scriptToRun)

On Error GoTo 0

End If

Nov 5, 2015 1:28 PM in response to SergioDoglioli

Hi,


I get the problem with Filemaker 14 about the attachment. So I search back my old applescript to do it. It doesn't work to. With mistake and trying, I understand than the "Mail" send the email before it get the attachment. So with a small "delay" before sending the email, everything work like before (but it's just not really efficient and I really don't like to use the "delay" function. But it's the sample way I found!)

I try to read the attachment in the send message. Just to say "wait until attachment exist", but it's just doesn't work. So I live with 1 sec of delay!


Hope this will help!


Hope than Apple or Filemaker will do something more than say: "oh it's doesn't work anymore!" ?


Have fun

Dec 17, 2015 11:45 PM in response to stevejobsfan0123

Adding my name to the list of people with this problem, mine is with a Hazel Finder script to email a PDF file. I'm often not present when this script runs so any solution that requires input from me won't solve my problems.


Same situation as others, Applescript to send mail with attachment works fine under Mavericks but fails under El Capitan. The email goes out without the attachment.


Unfortunately setting a delay n the script, even many seconds delay, doesn't help.


Something is broken with email attachment Applescript scripting in mail under El Capitan. I'm having to use an old underpowered Maverick Laptop to run these scripts until it's fixed or I can make a workaround work.

Dec 30, 2015 4:47 AM in response to GuruMeditationError

This thread has been rendered a confusing mess by people hijacking it. If you want to ask your own question start a new thread please. I came to this thread because I had a similar problem to the OP now instead of reading solutions to the problem I'm reading I've got a problem with Entourage, I've got a problem with my toilet seat. Okay, lovely dear but not helping.

AppleScript to Send Mail in El Capitan

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.