[Update]: This post was updated on August 11, 2016.
When a company migrates mailboxes between Exchange servers, they run the risk of losing emails that were in message queues. The gravity of this problem increases with the size of the organization and the amount of mail traffic – when hundreds of emails are sent every hour, the danger of overlooking them during the switch is quite high.
Fortunately, a simple PowerShell script is all you need to avoid the setback. It is even useful as a final checkup measure before decommissioning the old server. Below you’ll find steps required to perform this task.
First, launch the Exchange Management Shell or connect to your server remotely using the PowerShell console.
Run the following command to suspend all messages in all queues on your server. Only suspended messages can be exported.
Get-Queue | Get-Message | Suspend-Message
Next retrieve all messages from your queues:
$MailExport = Get-Message
Before saving exported messages on the hard drive, make sure to create a folder for their storage, e.g. c:\queuexport.
Use the following command to export messages:
$MailExport | ForEach-Object {$temporary="C:\queuexport\"+$_.fromaddress+"_"+$_.subject+".eml"; export-message $_.identity | assemblemessage -path $temporary}
All messages found in all queues are saved to the C:\queuexport folder in the standard EML format with file names consisting of the sender’s email address, the message’s subject.
You can then easily import these emails into Outlook by simply dragging and dropping them in any mail folder.
The procedure is compatible with Exchange 2010, Exchange 2013, Exchange 2016 and Exchange 2019.
Hello, thanks for your info. in my case several internal emails are put poison message queue that I cannot suspend. any suguestion to redirect poison message queue and resubmit it?
I may sound like a confirmation message, but are you sure you want to resubmit everything from the poison message queue? Emails in there might be corrupted and harmful to your server.
The reason you cannot suspend them is simple: emails in the poison message queue are already suspended.
To resubmit messages from the poison message queue, you can follow the steps from the following TechNet article Procedures for queues.
Thanks for sharing this informative post. I believe that this post will definitely solve the problems and issues related to migration of emails. Moreover, this is a manual method which doesn’t involve any cost for migration.