Help on a Mac Automator Workflow - Add Attachment to Email

Hello, I am trying to create a Hazel rules that watches for a newly scanned document in a folder, triggers an Automator workflow to create and send an email with the .pdf scan attached, and then deletes the .pdf scan. The Hazel rule works fine, but I’m having trouble with the Automator workflow.

The Automator workflow will create a new email with the appropriate addressee and email body information. However, instead of including the actual attachment, only the file path is included in the email. I have attached a couple of picture: (1) workflow automation steps and (2) resulting email.

Any ideas or suggestions how to get the Automator workflow working? Thanks in advance!

Bruce

Have you considered using Hazel for the whole rule? I think (and I may be wrong, having just woken up and not tested this), that if you use Hazel to open the file in Mail it will attach it to an email, and then you could use text expansion to write the subject and email body for you.

Thanks, Rosemary.

I am hoping for this process to be entirely automatic without any user intervention. I couldn’t figure out how to use Hazel to send the email. It does look like there’s an option to open Mail via Hazel, but I couldn’t figure out an easy way to automatically send the email.

Hazel does have an option to use AppleScript and I initially tried that to create and send the email using some code I found online. In the end, I wasn’t able to get the AppleScript code to work and then switched to trying Automator. I’d be open to trying AppleScript again, but that’s a bit beyond my current capabilities. :grinning:

Thanks!

Was the script you tried from the Noodlesoft Forums?

https://www.noodlesoft.com/forums/viewtopic.php?t=3405

Yes. The script created and sent the email just fine, but didn’t attach the .pdf document. I’m guessing I’m missing something with how I copied/pasted and then edited the script. Or, perhaps Mojave has some setting that I don’t have checked or unchecked, but I do have the Mail app checked in System Preferences > Security & Privacy > Automation.

Here are screenshots of the Hazel setup and embedded AppleScript.

Thanks for your help!

Bruce

I figured it out!

I saw another post online about issues with Mojave and suggestions to: (1) activate Mail.app and (2) add a delay. I did both and that fixed the issue such that the attachment was added before the email was sent.

I experimented to remove item #1 (activate Mail.app) and the automation still worked so I think the true fix was adding a delay to allow the attachment to be added to the email before it was sent.

Below is my final embedded script in case it helps others (the red box shows where I added a delay).

Thanks!