Files Mailed Magically When Dropped in a Finder Folder
There must be someone you email stuff to all the time. Maybe you send your mom pictures. Or you send an agenda to your boss every day. That can take a lot of clicks. Open Mail. Create a message. Address it. Attach the file. Write a subject. Sounds like a lot of work.
Instead, watch this Snippet. You can create an action that grabs every file you add to a folder and mails it off to a pre-configured address. Click to see an example. Or click Watch Now below to see how to set it up.
Murphy uses this as a crude backup tool. He drops key files to a folder and they are instantly whisked away to a free email service. Quick and convenient archiving.
What do you think? Too lazy?
Bonus: Murphy has provided a Folder Action script that prompts for a subject before sending the attachment.
or Download Script w/ Subject Prompt
Update, June 2007: See this new post on this subject.
8. December 2006 at 8:01 am :
Thanks for another useful snippet. Anything on Applescript is really useful for me, its part of my Mac arsenal that I have never dedicated enough time to getting to grips with, but it always proves really useful when I do…
17. December 2006 at 2:57 pm :
This was a great tutorial. I set up four folders for people I most send files to. It works great! I am a relative newbie to OS X. Tricks like this show how powerful OS X is right out of the box. Is it possible to have the file automatically deleted from the “mailer folder” after it is mailed?
17. January 2007 at 4:20 pm :
Good idea but I don’t understand the point of using a folder action. Why not compiling the script as a drop box? It would be easier to set up (no messing around with the folder actions) and also the file to be sent will stay were it is instead of going inside the folder.
17. January 2007 at 10:59 pm :
Now..if i could just get this script to stop sending .DS_store files as well.
19. January 2007 at 6:08 am :
I wanted to use something like this to use my gmail account as a backup and net accessible storage. But along with automatically sending the email, I wanted to have the filename of the document automatically be the subject of the email so that my new archive could be easily searched. Also, like Olivier, I wanted an icon to drop things on, not a folder. Here’s Murphy’s script with those changes made (in the script editor you would save it as an app, otherwise use is the same as in the snippet):
on open files_
repeat with eachitem in files_
set theSender to “”
set recipCommon to “”
set recipAddress to “”
set msgText to “”
set iteminfo to info for eachitem
set theSubject to name of iteminfo
tell application “Mail”
set newmessage to make new outgoing message with properties {content:msgText & return}
tell newmessage
set visible to true
set sender to theSender
set subject to theSubject
make new to recipient with properties {name:recipCommon, address:recipAddress}
make new attachment with properties {file name:eachitem} at after the last paragraph
end tell
send newmessage
end tell
end repeat
end open
19. January 2007 at 7:18 am :
Excellent. Thanks Chris.
I must say the TUAW thing caught me off guard, I haven’t messed much with droplets. More material for future snippets!
29. January 2007 at 10:26 pm :
Thank you Murphy and Chris Holden, this thing is extremely useful for me.
Can anyone point me somplace I can learn to write this code? Right now it can’t seem to handle more than one file being dropped on it at a time and I’d like to try to fix that.
But thanks again,
William
31. January 2007 at 3:26 pm :
I don’t have a set person I send things to all the time, but I really love the drag and drop feature of taking a file and dropping it on top of the Mail icon to open/new/attach. It’s a good thing.
15. March 2007 at 10:25 pm :
I cant seem to set up my mail account. whenever I get to the general information part of the mail setup i cant seem to get it right with the info. can u guide me through it. Thanks abunch murph
12. April 2007 at 12:37 am :
Do you have any idea murph?
12. April 2007 at 5:16 am :
Malvern -
Try these instructions.
5. May 2007 at 3:53 am :
Is there any way to ammend this script to email a list of files that has been added to a folder instead of actually sending the file? I would like to be able to add files to a certain folder and then have someone receive an email (perhaps a sort of daily digest) that tells them exactly what files have been added so that they can then browse to the folder and see the files at their own leisure. Some of the files are large video files, hence the reason I don’t want to email them direct.
Cheers
5. May 2007 at 9:47 pm :
I would set up the folder to run a shell script. Your shell script could run something like this:
find . -cmin -10 | xargs basename>newfiles.txt
That would give you a text file called newfiles.txt listing files in the current directory changed in the last 10 minutes. Adjust the 10 for whatever you need.
Then use cp or mv in a shell script to move the newfiles.txt file to a folder set up like this post - which will mail the file. You could get fancier and append some other text with the cat command.
I have a post about creating shell scripts. You should look at the other Terminal screencasts too. The cat command is mentioned in a few of them.
You’ll probably need to kick off your shell script from an AppleScript. Checkout Do Shell Script for that.
I’m not sure I’d do the whole thing as a folder actions - at least not with the way my script works. My script sends every file added to the folder in a separate email. I don’t think you want a notification email going out for EACH file you add to the folder.
Instead, you could have the script run once a day or every hour or whatever - and it would see what was new and send an email with the list of new files inside it.
6. May 2007 at 11:59 am :
Thanks for your suggestions Murphy - that was extremely helpful of you. Having thought about it a little bit more tho, I think I have decided to create a droplet which I can drop the files I want on the network drive onto and then have it automatically copy the files to the correct location on the network drive and also create and mail a list of files that have been dropped onto it. That has the benefit of not needing to set up a cron job and not using sytem resources (however negligible) when it is running on schedule. If I actually manage to get a script working, I’ll post it over to you.
17. May 2007 at 6:01 pm :
Thank you so much for your great tutorial murph. I have a limited knowledge of this area but found your instructions extremely easy to follow. However is there anyway to have a dialog box pop up which asks you: to stick with the default text entry for the body OR to type a unique one for this particular email?? As in: “Body of message…” and below an area to type and below that with two buttons: ‘accept’ or ‘revert to default’.
Is this possible? If not, then just a place to type the body of the email with no default text to revert to.
Cheers for a super website
Dave
20. May 2007 at 10:14 pm :
I’ve just submitted a new version of this tutorial to a contest and can direct you to the entry this week. The new version covers two ways to make this work - one with AppleScript and one with Automator. The Automator one makes it pretty easy to do what you want.
21. July 2007 at 1:42 am :
This is exactly what I expected to find out after reading the title es Mailed Magically When Dropped in a Finder Folder - Murphy Mac. Thanks for informative article
24. August 2007 at 9:07 pm :
Love the script, but I would also like to mail the file names only. as I have a ftp server that would need to send to separate people with newly received files.
24. August 2007 at 9:52 pm :
Never mind, I got it. set iteminfo for eachitem and msgText to iteminfo.
25. September 2007 at 3:37 pm :
Sweet! script,
The files i’m emailing are text how would i get it to display in the body instead of them being attached.
Joe
19. October 2007 at 1:00 am :
Excellent Work murphy!! A few quick queries though…
1. Is it possible just like the subject prompt, a prompt for thee recipient address is alos there. What I mean is everytime I am asked to enter not only the subject but the email address I want to send it to???
2. More importantly can this script be made to run of the Thunderbird application??
2. November 2007 at 3:38 pm :
Hi! Looks like fun, but it’s not working for me: the file sits in the folder and nothing happens: the file sits in the folder, the finder blinks once as if something is supposed to happen, but nothing appears in Mail’s OUT or SEND boxes. I’m running Leopard: has anybody checked it out on this new os? Or maybe I need to be a big bog and learn how to troubleshoot apple scripts?
8. November 2007 at 12:22 am :
Bruce, I got exactly the same result as you. Maybe it is a Leopard issue?
8. November 2007 at 3:53 am :
I’ll try it out tomorrow. I just installed Leopard tonight.
8. November 2007 at 5:35 pm :
I only messed with this for a few minutes, but I don’t see any Folder Actions working. I tried using the ones that come with the OS, like add- new item alert.scpt and that didn’t run when I added something to the folder. So - something might be going on here that has nothing to do with this particular script.
23. November 2007 at 9:34 pm :
Awesome!!!!!! How do I tweak it so that it asks me the recipients address every time I send an email. That is how do I make it prompt me for an address as well??
24. November 2007 at 1:30 am :
Check out the newer version of this screencast. It shows how to make an automator action that does just what you want…
Let me know if you have trouble.
http://murphymac.com/new-and-improved-finder-emailing/
7. December 2007 at 9:39 am :
Hi,
Thanks…….i am new to apple script..i need to know hoe to set the folder…moreover i need to just watch the folder in my server and not through any mail…please help me..
7. December 2007 at 10:30 am :
Hi,
Thanks very much………it is working great……
9. December 2007 at 12:45 am :
If you’re having trouble getting folder action scripts to work in Leopard check the permissions. Make sure they’re like the permissions on the built in script files. I had trouble getting this working until I duplicated an existing script file and pasted in the script text.
17. December 2007 at 4:21 am :
Hi,
Ur watch folder is working fine.I need apple script to run this watch folder for 4 or 5 folders using apple script……..
9. January 2008 at 6:28 am :
How can I use the mailer script on a network folder so everyone on my network can benefit from it?
10. April 2008 at 5:00 pm :
how can i make it stop sending .ds files.
also any way i can change the script so that file name/names will be automatically used as subject line.
I tried to use chris holden’s script. But it is causing syntax errors.
BTW, i use leopard.
Thanks for all the help
10. April 2008 at 5:16 pm :
Great script. I am looking for something like that. I would like to sync my folder with a FTP server using SFTP. Is it possible to do that. If you can you help me on that.
Thanks
15. April 2008 at 9:08 pm :
hi i love your script, but I use entourage (on leopard). i tried simply swapping the tell application “mail” command with “microsoft entourage”.
Then when i tried to save the script it kept reporting that there is a syntax error, in the line: “make new attachment with properties {file name:eachitem} at after the last paragraph” - the word “name” is highlighted and the error message says: “Expected “:”, etc. but found property.” So then I joined fiddled with the word “name” deleting it, deleting the space between it and file, and the result is that when i enable the folder action and drag a file into it, i find a new email in my entourage drafts folder, which has the correct sender, recipient, subject and text, but no file attached, and it is not sent. any suggestions?
thanks
15. April 2008 at 9:31 pm :
Wow - I wouldn’t have expected that you’d get that far that easily!
You need to look in the Applescript Dictionary to see what commands it uses with Entourage. If you don’t get anywhere I’ll post something on the site seeing if anyone can help you, as it would probably help many people.
When your script editor is open click on File >> Open Dictionary and then look or Microsoft Entourage in the list.
Actually - according to this thread it looks a lot like it would with Mail. Let me know if you get it working - or if you’re stuck.
http://forums.macrumors.com/showthread.php?t=433408
1. July 2008 at 12:10 pm :
Hey Murphy,
I’ve been trying out your script on a Leopard machine but getting some fairly erratic results. I tried your permissions thing from above but that hasn’t helped.
It seems there is a maximum of 7 emails with file attachments that will automatically get sent with the 8th always stopping just before inputting the recipient name.
Notably, when I use another script to move files from several other locaitons into my “Send Mail” folder to which this script is attached, it does exactly the same same thing but this time on the 1st message.
Just wondering if you knew of any conflicts or limitations that might be causing this.