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

Need AppleScript to move email to another folder

I need an Applescript to move emails from one folder to another.


Does anyone have an AppleScript that would do that, or could give me instructions?


I haven’t done AppleScript before, but I know FileMaker Programming.


It would work something like this:


In Mail (Mavericks)

Go to Import folder

Go to 0001 (sub-folder in Import folder)

get email message (there’s only one)

Move that email to Email Archive folder (still in Mail)


Go to 0002 (next folder in Import folder)

Move that email to Email Archive folder


Loops through all 1,000 folders, all inside Import folder.


More info, Here’s what happened:

I kept having problems with my Mac, so I finally decided to do a clean install of Mavericks.

I first backed up all my files by copying them to a new hard drive.

Turns out, the mail files are hidden. So, when I copied all folders to a new hard drive, all my mail got left behind. I hate this new design; that they now hide email files.


I then formatted my hard drive and erased all my email. (Whoops!)

I then re-installed Mavericks, that worked, but I soon discovered I didn’t have my email.


I took my Mac to a Data Recovery service, and

Good News! They were able to recover some of my email.


They gave me several folders of individual .emlx email files.


I tried to import one folder into Mail, and the emails ended in up 1,000 separate folders, all under an Import Folder.


I need an AppleScript to take 1,000 emails, one at a time, currently all in separate folders, and move them to an Archive folder.


Could someone help me?


Thank you,

Larry

MacBook Pro, OS X Mavericks (10.9.1)

Posted on May 6, 2014 10:48 PM

Reply
Question marked as Best reply

Posted on May 7, 2014 8:26 AM

Try this:


tell application "Mail"

repeat with theMessage in (every message of every mailbox of (mailbox "Import folder"))

set mailbox of theMessage to mailbox "Archive"

end repeat

end tell

3 replies

Jan 19, 2015 11:02 AM in response to Tree_Farmer

I was looking for the same solution, to move messages to a folder and using the dictionary I found this to work in Yosemite.



tell application "Mail"


set the_messages to selection

repeat with this_message in the_messages

set theSender to sender of this_message


# set theSendersAddress to extract address from sender of this_message

move this_message to mailbox "BILL PAY/Mortgage & HOA" of account "iCloud" -- a folder contained by another folder


end repeat

end tell

Need AppleScript to move email to another folder

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