How to Export Messages from a Mail Queue on Exchange

It is possible to export one or all messages from one specific or all queues on an Exchange Server. This post describes how to do it for Exchange 2010, but the process is quite similar on Exchange 2013.

To do the export of messages, you can use the Export-Message cmdlet, which is part of Exchange. If you want to resubmit the exported mails (now .eml files), then put them into the replay directory on another Exchange server.

The default directory for the Replay Directory (on Exchange 2010) is:

C:Program FilesMicrosoftExchange ServerV14TransportRolesReplay

The Script:

#Suspend all messages in the queue
get-queue ExchangeServer501| Get-Message | Suspend-Message
#Get all messages from the queue
$array = @(Get-Message -Queue “ExchangeServer501” -ResultSize unlimited)
#Export all messages from the queu
$array | ForEach-Object {$i++;Export-Message $_.Identity | AssembleMessage -Path (“E:Mailqueue”+ $i +”.eml”)}

Find your Queue ID (Mine was ExchangeServer501) using Get-Queue.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s