Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript needed to move Mail attachment to folder

Hi,


I am in need of a script to add to a Mail Rule that will take an attached image (JPEG) and place it in a folder with the name indicated in the body "message" section of the email, and also renaming that file.


Example:



Rule will use "Subject" - "contains" - "Xfer Image"


The email will contain something like this in the body "message" section of the email.


itemName - Rose_Flower_001.

itemNumber - Fl-652



I would like the mailed JPEG image Attachment copied over to a folder called (itemName) which would be place within the following path:


(Folder with the itemName) ( file renamed to itemNumber)


"/Volumes/Ron/Dropbox/Images/Rose_Flower_001/Fl-621.jpg


Then after it's done this I would like to have the that email moved from the inbox to a sub-folder called "Image Folder Created"


Any and all help or suggestions would be greatly appriciated.



Hopefully this can be done....

I really need this for my start-up business and it would save me a lot of time making folders and managing emails with attachments.



Thanks in advance....


Ron

iMac, Mac OS X (10.7.3)

Posted on Apr 22, 2013 5:52 PM

Reply
31 replies

Apr 23, 2013 4:05 PM in response to Pierre L.

Sure man, no problem.


I am going to study the AppleScript Language Guide.. thanks.


Now there is one last thing that Ron wanted to do:


Then after it's done this I would like to have the that email moved from the inbox to a sub-folder called "Image Folder Created"


I am just not sure if he wants the email in a sub-folder of the folder he created in the dropbox, or on his desktop. Anyway, hopefully he answers you.

Apr 23, 2013 6:15 PM in response to pjdube

I'm hoping to run this side business from my Home which unfortunity is using Mountain Lion.


I do have a Mac at work which is still on Lion I will try the script at work tomorrow. I'm sure it will work there.


Like you said, Hopefully someone else will read this, or your friend and can make it work on Mountain Lion OS.



Thanks Phil.... For helping me... You have no Idea how much I appriciate this!




PS..... I'm re-thinking Mountain Lion. I have had so many scripts and application break since my upgrade.



You Rock!


Ron

Apr 23, 2013 6:35 PM in response to Pierre L.

Pierre.... I got confused with the two people posting on this Discussion site.


Thanks so much! I'm really excited to try this out at work tomorrow.


I hope I can run it sometime soon at home on Mountain Lion.


I really appriciate all your time taken to help me. I hate that Lion and Mountain Lion are so different in running things. I've had nothing but headaches since I installed Mountain Lion.


Hopefully someone will come up with a Mountain Lion version of your great script.

I can't wait till tomorrow to try it.


Ron


You Rock!

Apr 23, 2013 7:58 PM in response to Ron60

That's great that it works man.


So I got a reply from red_menaceon why it wouldn't work in Mountain Lion, and this is below. But now that you have this working, then I guess it is not needed. But you should have it anyway, if something occurs.


There appears to be a bug in Mountain Lion's Mail when using POP accounts that causes an error when getting the messages passed to the handler. It has to do with with Mail indexing an incorrect incoming mailbox, but there are a couple of workarounds.

  1. Relay your POP messages through an IMAP account
  2. Run an external script or modify the rule to process messages in your incoming mail box


For an example of workaround #2, to get the unread messages in your inbox change the initial messages repeat loop to something like:


repeatwiththeMessagein (messagesofinboxwhoseread statusisfalse)


Of course, you will need to read or move the messages out of the inbox so that they don't get repeocessed when receiving further messages that trigger the rule.

Apr 24, 2013 1:22 AM in response to pjdube

FYI


At first It worked on a few images and not on others.... Then I noticed that the image was still downloading while the scrpt was running. So I added a "delay 60" at the front of the script so that it allows time for the images to download. That seem to make it a bit more stable in catching all the images.


Thanks Pierre ..... It's working great!

Sep 4, 2013 4:39 PM in response to Ron60

Please help. I need a "simple" applestcript that can move or copy any picture attachment that ends with .jpg and move it (preferably) or copy it to a specific folder I setup on my HD. I can set the mail "rules" for this but I know nothing about writing applescript. They'll be a little something extra in your christmas stocking for the person who does this :-)

Applescript needed to move Mail attachment to folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.