Email Notification - Applescript To Add File Name In Subject

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

Moderator: Mr_Noodle

Hello

Using Hazel for the first time to watch folders and send out an email notification when a file arrives in the folder.

What do I need in my Applescript Example below to have the Filename show up in the subject line?

Thanks in advance for any help.

tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:"Hello from your Mac!", content:"You got a new file in your Downloads folder, girl!", visible:true}
tell theNewMessage
make new to recipient at end of to recipients with properties {address:"EMAILADDRESS@EMAIL.COM"}
send
end tell
end tell
MacWorks
 
Posts: 6
Joined: Thu Sep 18, 2014 1:52 pm

The variable "theFile" refers to the file so you need to extract the name of the file from that. This isn't Hazel-specific so I suggest searching around for more general AppleScript resources out there.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support