Page 1 of 1

Can't send mail attachment after El Capitan upgrade

PostPosted: Wed Nov 25, 2015 12:38 pm
by lineskc
I am having trouble with an AppleScript attached to a hazel rule since upgrading to El Capitan. the script is supposed to email a file as an attachment to someone. It used to work flawlessly and since upgrading, it will still send the email, but without the attachment. Please help! I have included the script text and picture below for reference. Note: I changed the email to a generic one for this forum. Also, I have checked that I have added the item to the inputAttributes.

tell application "Mail"

set theMessage to make new outgoing message with properties {visible:true, subject:"R/M Chart " & (item 1 of inputAttributes), sender:"myemail@myemail.com"}

tell theMessage
make new to recipient at end of to recipients with properties {address:"myemail@myemail.com"}
make new attachment with properties {file name:theFile} at after the last character
send
end tell

end tell

Re: Can't send mail attachment after El Capitan upgrade

PostPosted: Wed Nov 25, 2015 1:27 pm
by Mr_Noodle
Did you email about this? If so, I responded there but just in case: it's Apple's bug. Also, in the future, please only post/email to one place so I don't have to reply twice.

Re: Can't send mail attachment after El Capitan upgrade

PostPosted: Wed Nov 25, 2015 4:42 pm
by lineskc
Sorry about that. I didn't realize you see forums and help with support via email.

Re: Can't send mail attachment after El Capitan upgrade

PostPosted: Thu Dec 17, 2015 10:49 am
by MacOCD
Mr_Noodle...Would it be possible to expand on your reply about this on these forums please?

I'm in the same situation, attachments aren't sending after El-Capitan upgrade using scripts that still work on Yosemite.

Is this something likely to be fixed by Apple? Is it a bug? or something where the additional security of El-Capitan has broken things for us?

Would disabling SIP (System Integrity Protection) in El-Capitan resolve the issue?

Does anyone have a workaround?

Thanks,
Mark.

Re: Can't send mail attachment after El Capitan upgrade

PostPosted: Thu Dec 17, 2015 12:05 pm
by Mr_Noodle
I don't think it's SIP related at all. It's just Apple breaking stuff. I can't say how likely it is they will fix it. I have a long list of bugs over the years that still haven't been fixed and it's rarely predictable which ones do get addressed. I suggest contacting them to provide more votes as to the severity of this issue.

As for workaround, you can try another email client or maybe find some sort of web service that can send the email with the attachment. Those have their own issues with how to script them though.

Re: Can't send mail attachment after El Capitan upgrade

PostPosted: Fri Dec 18, 2015 8:38 am
by MacOCD
Thanks for your time.

Having researched other sources on this problem I've "resolved" the issue by adding a significant delay immediately before issuing the "Send" command in the script.

I did try this earlier and it didn't work, but setting a longer, 5 second delay seems to have done the trick for now.

I do send quite a few PDFs using my script so 5 seconds per document pollutes my system for a little while, but the job gets done :)

Re: Can't send mail attachment after El Capitan upgrade

PostPosted: Fri Dec 18, 2015 12:35 pm
by Mr_Noodle
Actually, posting about using a delay will be helpful to others as I wasn't aware it was a timing issue. Not ideal but it's better than it not working at all.

Re: Can't send mail attachment after El Capitan upgrade

PostPosted: Sun Jan 24, 2016 6:00 am
by matthewp
Thanks MacOCD, my recent update to El Capitan broke my applescripts that attach files to emails. I added "Delay 5" in the line just before send.

Here is the script I use:
Code: Select all
set theAttachment1 to (POSIX path of theFile)
set subject_ to "subject"
set the_content to "the_content"
tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:subject_, content:the_content & return & return}
    tell newMessage

        set visible to false
        set sender to "xx@xxx.xx"
        make new to recipient at end of to recipients with properties {address:"RECIPIENT@xxx.com"}
        make new attachment with properties {file name:theAttachment1} at after the last paragraph
delay 5
      send
    end tell
end tell

I didn't write it, but thought I'd share it in case it helps others.