I’m new to scripting, started yesterday with automatically moving files.
I want to have mail automatically send an email with an attached file every time a new file is added to a folder. The idea is that every time I add a school/work-related file it will be mailed to my Drop.io so I’ll have access to it elsewhere.
on adding folder items to thisFolder after receiving theseFiles
tell application "Mail"
set theMessage to make new outgoing message with properties {visible:true, subject:"The Subject", content:"The Body"}
tell theMessage
make new to recipient at end of to recipients with properties {name:"Drop.io", address:"xxxxxxx@drop.io"}
end tell
tell content of theMessage
make new attachment with properties {file name:theseFiles} at after last paragraph
end tell
end tell
end adding folder items to
When I attach the script to the folder and add a file nothing happens. When clicking run in script editor nothing happens either. I know the create and recipient code is right. I also know that the on adding folder items… part works at least in other applications.
Is there something I’m doing wrong here to get the script to run?
Thanks
EDIT:
Got the script to actually run (moved it to the folder actions folder…) The problem is, however, getting the attachment to actually work. It seems like theseFiles as the file name doesn’t work. Similarly it also seems that doing something like
set theAttachment to theseFiles
then filename:theAttachment doesn’t work either. When I was reading up on it this was the method, only theAttachment was set to a specific file, or so it seemed.
Is there anyone who can clarify or point me in the right direction to do this correctly.
Thanks again