Extract data from Outlook and MAPI stores

mapitool.exe converts Outlook and Exchange message stores, such as .pst files, to .msg files. Each message or other item is converted to a .msg file, with the Outlook or Exchange folder structure mirrored in the directory structure of the output files. Attachments are included in the .msg files.

Use mapitool.exe if you have the 32-bit version of Outlook and mapitool64.exe if you have the 64-bit version of Outlook.

After extracting messages, check the errors.txt file in the output folder for any errors that may have occurred.

Command-line options:
-lf             List folders in default profile
-lp             List profiles (default profile will be marked with *)
-xm dest-folder Extract all messages in .MSG file to folder name dest-folder
-pst filename   Use specified PST file instead of an existing profile
-log            Enable debug logging
-c	        Choose Outlook folder to extract (use with -xm)
-t "template"   Provide a custom template for extracted item names.
                Use these symbols in the template:
                %%Sender%% 		Sender name (email address)
                %%SenderName%% 		Sender name
                %%SenderEmail%% 	Sender email address
                %%Subject%% 		Message subject
                %%RecordKey%% 		MAPI-generated unique code
			                identifying this message in the store
		%%Ordinal%% 		A counter incremented for each message
		Note: Either Ordinal or RecordKey should be included to
		ensure that each message has a unique name.
-maxr N         Use workaround for KB 171907 MAPI bug for items
                with more than N recipients (default=25)


mapitool -xm c:\Messages
Extract all messages from the default profile and store them in a folder tree under c:\Messages.

mapitool -xm c:\Messages -pst c:\Input\Smith.pst
Extract all messages from Smith.pst and store them in a folder tree under c:\Messages

mapitool -xm c:\Messages -c
Choose a folder from the Outlook folder tree and extract all messages from that folder (and any subfolders) to c:\Messages

mapitool -xm c:\temp\msg -c -t "%%Sender%% - %%Subject%% [%%RecordKey%%].msg"
Choose a folder from the Outlook folder tree and extract all messages from that folder (and any subfolders) to c:\temp\msg, using a custom template for the name of each message.

In DOS batch scripts, the % character has to be escaped as %%, so %%Subject%% would be %%%%Subject%%%%. To simplify use in batch scripts the # character can be used instead of % in the replacement strings. Example:

mapitool -xm c:\temp\msg -c -t "##Sender## - ##Subject## [##Ordinal##].msg"

Extracting messages with large distribution lists

Mapitool exports messages to .msg files using the MAPI "CopyTo" API call.  This API can fail with a MAPI_E_NOT_ENOUGH_MEMORY error when a message has a large number of recipients, no matter how much memory the system has, due to a limitation in MAPI.  For more information on this error, see

To work around this limitation, Mapitool uses a different mechanism to extract distribution lists when a message has more than 25 recipients.  For these messages, the distribution list is not exported with the .msg file using CopyTo and instead is added to a separate "_Recipients_" stream that is inserted in the .msg file.  When a .msg file is created using this alternative method, the complete recipient list is searchable and visible in dtSearch, but the recipient list will not be visible if you open the .msg file in Microsoft Outlook.


Copyright 2004-2017 dtSearch Corp. All Rights Reserved.