I’ve found some code from this thread: Microsoft Outlook Script to add attachment that works perfectly (thanks @wasabi) but I want to adapt it to be available in the Share menu, especially in Preview.
I’m struggling with how to take the input parameter in Automator’s Run AppleScript and use that to get filenames into the appropriate variables.
I’ve taken the final working code and pasted it below. I’ve changed “selectedItem” to input but that’s generating an error: "Can’t get name of {alias “Path to selected file”} where Path to selected file is the full colon separated path.
I’m hoping to add functionality to deal with multiple selected files in the Finder and eventually add the ability to compress folders.
But first, I want to get the basics working.
Thanks.
Cheers,
Jon
tell application "Finder" to set selectedItem to item 1 of (get selection)
set theAttachment to selectedItem as alias
set fileName to name of selectedItem
tell application "Microsoft Outlook"
set newMessage to make new outgoing message with properties {subject:fileName}
tell newMessage
make new attachment with properties {file:theAttachment}
end tell
open newMessage
get newMessage
end tell