I attach the same file into outlook emails on a regular basis. I am new to Keyboard Maestro and have googled attach a file to an outlook email. There are several posts about it, with several attempts to do it. So far none of the attempts I have found have worked. It looks like executing an AppleScript might be the best way to accomplish this. So I tried to right this little script, using the Mac script editor. It would not let me save it until I got all of the syntax errors corrected. But nothing happens when I try to run the script.
This is what I have:
set fileattach to "Users/path/file.pdf"
tellapplication "Microsoft Outlook"
make new attachment with properties{file:fileattach}
endtell
If you have managed to get it to work and can tell me what I have done wrong that would be great.
It's very difficult to use AS to add an attachment -- unless you also use AS to create the outgoing mail in the first place. If you don't then the easiest way is use KM to send ⌘E and drive the standard dialog.
Perhaps if you explained the workflow you are trying to achieve?
Try this. It'll replace steps 2 and 3 in your workflow, and you can either call your current "Standard Reply" macro by adding an "Execute Macro" action at the end or copy that macro's actions over to this one.
It'll work on a single selected message, making a reply with an attachment. Change the second line of the AppleScript:
set theFile to alias "Macintosh HD:Users:nigel:Desktop:Test PDF.pdf"
...to point to your file -- so if it's the file "Standard Form.xlsx" in the folder "Forms" in your "Documents" folder and your home folder is "steve" then
set theFile to alias "Macintosh HD:Users:steve:Documents:Forms:Standard Form.xlsx"
Tested on Legacy Outlook, but should work with New Outlook too (I'll check when I get home).
I hadn't -- but I have now and it completely fails in New Outlook (which is even worse at AppleScript than I remembered...).
If you want to do lots of Outlook automation consider switching back to Legacy Outlook (and don't forget to tell them why in the dialog that comes up). IMO, Legacy is a better, more feature-complete, version anyway.
If you want, or have to, continue with the hobbled New Outlook you'll have to drive the UI. This will show you how -- put the path to your attachment in the first action: