I'm trying to setup a Watch Folder in AppleScript which is over a home network. I want the script to generate an email when a file (or files) is dropped in the Watch Folder. How can I achieve this?
1 Answer
Save a script like this in ~/Library/Workflows/Applications/Folder Actions
:
on adding folder items to this_folder after receiving these_items
tell application "Mail"
tell (make new outgoing message)
make new recipient at end of to recipients with properties {address:"[email protected]"}
set subject to "subject"
set content to "content"
send
end tell
end tell
end adding folder items to
Then enable it from Folder Actions Setup:
Or if you want to add the files as attachments, add this before the send command:
repeat with f in these_items
make new attachment with properties {file name:f} at after paragraph -1
end repeat
Another way to send email is to use msmtp.