Email & Date Variable Script - HELP PLEASE !

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Need some help here with an email rule. The thread here is close to solving part of what I’m attempting: viewtopic.php?f=2&t=2453&p=10291&hilit=email+attachment#p10291

So, I have a rule that’s watching a folder for any file added today. When it detects a file, it runs the following Applescript:

Code: Select all
tell application "Microsoft Outlook" to activate

set recipientName to "Jerry"
set recipientAddress to "jerry@seinfeld.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, it’s 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 that’s solved my goal is to introduce a date variable into both the Subject and Content of the email, i.e. I’d like the script to auto-detect the current month and populate accordingly so that ‘Kramer’s Invoice’ becomes ‘Kramer’s July Invoice’ and ‘Please find Kramer’s invoice attached’ becomes ‘Please find Kramer’s July Invoice attached’.

I’m really out of my depth here so any help is greatly appreciated.

Thanks
vinyl_vibe
 
Posts: 22
Joined: Sat Mar 12, 2011 8:36 am

Have you tried this outside of Hazel? I suspect it might be a more general AppleScript thing.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I've run it through Script Editor but get the following error:

Expected expression, etc. but found “:”.

I've no idea what to make of that in the context of the script itself.
vinyl_vibe
 
Posts: 22
Joined: Sat Mar 12, 2011 8:36 am

It should point out where the error is happening but beyond that I can't say.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

This is all that's shown. Image

So it appears to happen after the file name but no indication of what I should replace it with.

If you can think of another way of me achieving what I'm after I'd be very greatful.

Thanks
vinyl_vibe
 
Posts: 22
Joined: Sat Mar 12, 2011 8:36 am

This is outside the support I can give. It seems to be an issue with Outlook's AppleScript so you'll have to find a forum more versed in that.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion