property groupName : "ImageGroup" --The name of the group of recipients, as named in Address Book
property subjectPrefix : "New image:" --Followed by the image name then used as the subject of the message
property messageContent : "" --The content of the message
property imageFormats : {"jpg", "jpeg"} --Valid formats for files added to the hot folder
on adding folder items to hotFolder after receiving newItems
--Cycle through each file
repeat with aFile in newItems
--Get information about the file
tell application "Finder"
set fileExtension to name extension of aFile
set filename to name of aFile
end tell
--Check that the file extension is valid
if fileExtension is in imageFormats then
tell application "Mail"
--Create the new message
set theSubject to subjectPrefix & " " & filename
set newMessage to make new outgoing message with properties {subject:theSubject, content:messageContent & return}
--Set the recipients and attach the file
make new to recipient at end of to recipients of newMessage with properties {address:groupName}
tell content of newMessage to make new attachment with properties {file name:aFile} at after the last paragraph
--Send the message
send newMessage
end tell
end if
end repeat
end adding folder items to