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.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20081019114709793