Outlook Applescript question

I have a Hazel rule thats watching a folder for any file added today. When it detects a file, it runs the following Applescript: 

tell application "Microsoft Outlook" to activate

set recipientName to "Jerry"
set recipientAddress to "email@email.com"
set theSubject to "Kramer's Invoice"
set theContent to "Please find Kramer's invoice attached.

Regards,
Jerry

"
set theAttachment to theFile

tell application "Microsoft Outlook"
   set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
   tell theMessage
      make new to recipient with properties {name:recipientName, address:recipientAddress}
      make new attachment with properties {file name:theAttachment} at after the last character
   end tell
end tell
For some reason when this rule is saved, its changing the second instance of tell application "Microsoft Outlook" to tell application "Mail. No matter how many times I try it just keeps changing it. Any thoughts on why and how to fix would be greatly appreciated. 

Once thats solved my goal is to introduce a date variable into both the Subject and Content of the email, i.e. Id like the script to auto-detect the current month and populate accordingly so that Kramers Invoice becomes Kramers July Invoice and Please find Kramers invoice attached becomes Please find Kramers July Invoice attached. 

Having raised this issue with the Hazel forum, Im told its an Applescript issue specific to Outlook. Ive tested the script outside of Hazel using Apples Script Editor and it returns an error: Expected expression, etc. but found :. Within the script itself, the editor is highlighting the colon after {file name:

Any thoughts on how I can resolve would be greatly appreciated. Thanks

July 16th, 2015 12:33pm

Hi,

This forum is for general questions and feedback related to Office for Windows. Since your question is more related to Outlook for Mac, I'd recommend you post a new question in the following forum:

http://answers.microsoft.com/en-us/mac/forum?tab=Threads

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Steve Fan
TechNet Community Support

Free Windows Admin Tool Kit Click here and download it now
July 17th, 2015 1:46am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics