Can't send mail attachment after El Capitan upgrade

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

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
lineskc
 
Posts: 3
Joined: Wed Nov 25, 2015 12:31 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Sorry about that. I didn't realize you see forums and help with support via email.
lineskc
 
Posts: 3
Joined: Wed Nov 25, 2015 12:31 pm

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.
MacOCD
 
Posts: 44
Joined: Fri Sep 26, 2014 11:02 am

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.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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 :)
MacOCD
 
Posts: 44
Joined: Fri Sep 26, 2014 11:02 am

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.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
matthewp
 
Posts: 18
Joined: Sun Jan 24, 2016 5:51 am


Return to Support