Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Move Mail messages to IMAP folder via AppleScript Apps
Error messages are sometimes encountered when moving messages to IMAP folders in Mail.app. This is especially annoying when moving large numbers of emails, as Mail then scraps the whole move. The following AppleScript gets around that problem -- it will only leave behind the problematic messages that cause errors.
tell application "Mail"
    set theSelectedMessages to selection
    repeat with theMessage in theSelectedMessages
        set theMailbox to "[Gmail]/Sent Mail"
        tell application "Mail"
            move the theMessage to mailbox theMailbox of account "Gmail IMAP"
         end tell
     end repeat
end tell
To use it, just change the account name Gmail IMAP to your account's name, and the folder from [Gmail]/Sent Mail to your IMAP folder's name. (As you can tell, I used this script to upload messages via GMail IMAP.) You can then save the script to your user's Library » Scripts » Applications » Mail folder and run it from the Scripts menu within Mail.

[robg adds: I haven't tested this one.]
    •    
  • Currently 2.00 / 5
  You rated: 1 / 5 (4 votes cast)
 
[17,318 views]  

Move Mail messages to IMAP folder via AppleScript | 6 comments | Create New Account
Click here to return to the 'Move Mail messages to IMAP folder via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Move Mail messages to IMAP folder via AppleScript
Authored by: monickels on Oct 22, '08 07:10:13AM

Thanks for this. I'm just now in the process of moving 144,000 messages to Gmail so I can use them with my new T-Mobile G1 Google phone. I hope this solves some of the errors.

---
A Way With Words: The lively public radio show about language. http://www. waywordradio.org/



[ Reply to This | # ]
Move Mail messages to IMAP folder via AppleScript
Authored by: aardvarko on Oct 22, '08 08:28:36AM
With long operations, a timeout parameter helps them complete without errors:

tell application "Mail"
    with timeout of 90000 seconds
        set theSelectedMessages to selection
        repeat with theMessage in theSelectedMessages
            set theMailbox to "[Gmail]/Sent Mail"
            tell application "Mail"
                move the theMessage to mailbox theMailbox of account "Gmail IMAP"
            end tell
        end repeat
    end timeout
end tell


[ Reply to This | # ]
Move Mail messages to IMAP folder via AppleScript
Authored by: mchmarny on Apr 02, '09 08:09:43AM

Dude, two days into the process of moving my emails I find this. The timeouts were killing me.

---
mark@chmarny.com



[ Reply to This | # ]
Move Mail messages to IMAP folder via AppleScript
Authored by: monickels on Oct 22, '08 08:40:29AM

The script definitely works, but only for folders that appear nested under [Gmail], such as "Sent Mail." Other folders, which appear in Mail.app at the same hierarchy level as [Gmail], do not seem to work with this script.

---
A Way With Words: The lively public radio show about language. http://waywordradio.org/



[ Reply to This | # ]
Move Mail messages to IMAP folder via AppleScript
Authored by: ClunkClunk on Oct 22, '08 08:55:15AM

I just spent a week moving 15,000 messages to my gmail account from an old pop account, and I encountered these errors all the time. I nearly had to babysit the move daily for some time.

Too bad this script wasn't out then :-)



[ Reply to This | # ]
Move Mail messages to IMAP folder via AppleScript
Authored by: 68882 on Oct 22, '08 06:21:09PM

Ok, having spent a week moving 300,000 some message I can report yet another way of doing this. If you take the account OFFLINE then drag and drop the folder on your mac to the GMAIL account, then Mail copyies all the mail to the .Cached folder. Later after it finishes that move, you put the account back on line. Then it wakes up and moves stuff from the .cached folder to the imap server, and later will tell you which msgs didn't move and makes a copy of them in your ON MAC folder for review.

So no applescript needed.



[ Reply to This | # ]