How to Export Messages from Queues
Microsoft Exchange Server 2007 will reach end of support on April 11, 2017. To stay supported, you will need to upgrade. For more information, see Resources to help you upgrade your Office 2007 servers and clients.
Applies to: Exchange Server 2007, Exchange Server 2007 SP1, Exchange Server 2007 SP2, Exchange Server 2007 SP3
This topic explains how to use the Exchange Management Shell to copy messages from a queue on a computer that has the Microsoft Exchange Server 2007 Hub Transport server role or the Edge Transport server role installed to a specified file path. You cannot use the Exchange Queue Viewer to perform this task. However, you can use the Queue Viewer to locate, identify, and suspend the messages before you perform this task.
When you export a message from a queue to a file, the message is not removed from the queue. A copy of the message is made in the specified location as a plain text file. The resulting file can be viewed in an application, such as a text editor or an e-mail client application. Or, the message file can be resubmitted by using the Replay directory on any other Hub Transport server or Edge Transport server either inside or outside the Exchange organization.
Before You Begin
To perform the following procedures, the account you use must be delegated the following:
- Exchange Server Administrator role and local Administrators group for the target server
To perform the following procedures on a computer that has the Edge Transport server role installed, you must log on by using an account that is a member of the local Administrators group on that computer.
For more information about permissions, delegating roles, and the rights that are required to administer Exchange Server 2007, see Permission Considerations.
Before you export a message from a queue, you must follow these steps:
Verify the following information about the target directory location:
The target directory must exist before you export any messages. The directory will not be created for you. If an absolute path is not specified, the current Exchange Management Shell working directory is used.
The path may be local to the Exchange 2007 computer, or it may be a Universal Naming Convention (UNC) path to a share on a remote server.
Your account must have the Write permission to the target directory.
Locate and identify the messages to be exported. For information about how to view messages, see How to View Messages.
Suspend the messages to be exported to prevent their delivery during the export process. The messages must be in a suspended state for the export process to be successful. You can export messages from remote delivery queues, mailbox delivery queues, the Unreachable queue, or the poison message queue. Messages that are in the poison message queue are already in a suspended state. If you are using Exchange 2007 SP2 or an earlier version, you cannot suspend or export messages that are in the Submission queue. However, you can suspend or export messages that are in the Submission queue if you are using Exchange 2007 SP3 or a later version. For information about how to suspend messages, see How to Suspend Messages.
Exporting Queued Messages to Files
Consider the following items when you plan to export queued messages to files:
Exporting messages from a queue doesn't remove the messages from the queue. If you export the messages to examine them, you can later resume the suspended messages for delivery. For more information about how to resume messages, see How to Resume Messages. If you export the messages and resubmit them by using the Replay directory, you should remove the suspended messages to avoid duplicate message delivery. For more information about how to remove messages from a queue, see How to Remove Messages from Queues.
You can export an individual message to a file by specifying a file name or a path and a file name. When you specify a file name, make sure that you include the .eml file name extension so that the file can be opened easily by e-mail client applications, or processed correctly by the Replay directory.
You can export messages to files with automatic file naming if you specify an export path to a directory that already exists. If the target directory already exists, the file name of each message is automatically set to InternalMessageID.eml. The InternalMessageID is a message identifier that is assigned by the Exchange 2007 server that is currently processing the message.
Exporting a Specific Message from a Specific Queue
To use the Exchange Management Shell to export a specific message from a specific queue to a file
Run the following command:
Export-Message -Identity <MessageIdentity> -Path <PathWithFileName>
For example, to export a copy of a message that has an InternalMessageID of 1234 that is located in the remote delivery queue for the domain "Contoso.com" on the server named Exchange01 to the path "C:\Contoso Export\export.eml", run the following command:
Export-Message -Identity ExchSrv1\contoso.com\1234 -Path "C:\Contoso Export\export.eml"
Exporting all the Messages from a Specific Queue
To use the Exchange Management Shell to export all the messages from a specific queue to a directory
Run the following command:
Get-Message -Queue "<QueueIdentity>" | Export-Message -Path "<LocalPath>"
For example, to export a copy of all the messages from the "Contoso.com" remote delivery queue on the server named Exchange01 to the directory "C:\Contoso Export" on the local computer, run the following command:
Get-Message -Queue "Exchange01\contoso.com" | Export-Message -Path "C:\Contoso Export"
Exporting Specific Messages from all the Queues on a Server
To use the Exchange Management Shell to export specific messages from all the queues on a server to a directory
Run the following command:
Get-Message -Filter {<Property> -<Operator> "<Value>"} -Server "<ServerIdentity>" | foreach {Export-Message -Identity:$_.Identity -Path "<LocalPath>"}
For example, to export a copy of all the messages from senders in the "Contoso.com" domain from all queues on the server named Exchange01 to the directory "C:\Contoso Export" on the local computer, run the following command:
Get-Message -Filter {FromAddress -like "@contoso.com"} -Server "Exchange01" | foreach {Export-Message -Identity:$_.Identity -Path:"C:\Contoso Export"}
For detailed syntax and parameter information, see Export-Message.
For more information about how to work with Exchange Management Shell command output, see Working with Command Output.
For More Information
For more information, see Using the Exchange Management Shell to Manage Queues.