Attach File to Outlook Email

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

Moderator: Mr_Noodle

Attach File to Outlook Email Wed Jan 02, 2019 7:01 pm • by HackerJL
Ive been playing with some automation, and tying it into Outlook, since Outlook disabled automator functions. I figured go hazel and never go back. Im having some issues with the AppleScript and attaching theFile. See below:
tell application "Microsoft Outlook"
set newMessage to make new outgoing message with properties {subject:"Invoices from Me"}
make new recipient at newMessage with properties {email address:{name:"Jim Shank", address:"jim.shank@example.com"}}
tell newMessage
repeat with aFile in SelectedItems -- the loop through all selected items
make new attachment with properties {file:theFile}
end repeat
end tell
open newMessage
get newMessage
end tell
return input


Any help would be appreciated.
HackerJL
 
Posts: 31
Joined: Thu Sep 22, 2011 6:28 pm

Re: Attach File to Outlook Email Thu Jan 03, 2019 10:21 am • by Mr_Noodle
What issues are you seeing exactly? Does the script work outside of Hazel?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Attach File to Outlook Email Thu Jan 03, 2019 3:47 pm • by HackerJL
Im seeing no attachment.

Outside of this, I took this from an automator script where I was playing until I thought hazel was better suited based on file triggers.

The version from automator is here:
on run {input, parameters}
set SelectedItems to input
tell application "Finder" to set fileName to name of first item of SelectedItems
tell application "Microsoft Outlook"
set newMessage to make new outgoing message with properties {subject:"Invoices from me"}
make new recipient at newMessage with properties {email address:{name:"Jim Shank", address:"jim.shank@example.com"}}
tell newMessage
repeat with aFile in SelectedItems -- the loop through all selected items
make new attachment with properties {file:aFile}
end repeat
end tell
open newMessage
get newMessage
end tell
return input
end run
HackerJL
 
Posts: 31
Joined: Thu Sep 22, 2011 6:28 pm

Re: Attach File to Outlook Email Fri Jan 04, 2019 1:31 pm • by Mr_Noodle
Again, though, does the script work outside of Hazel?

The script itself looks like it's relying on selected items. Probably not a good idea to have it rely on the current state of the UI at the time the script is run.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron