Page 1 of 1

Email Notification - Applescript To Add File Name In Subject

PostPosted: Fri Jun 05, 2015 1:16 pm
by MacWorks
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

Re: Email Notification - Applescript To Add File Name In Sub

PostPosted: Mon Jun 08, 2015 4:00 pm
by Mr_Noodle
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.