How to Remove Attachments from Exchange Mailbox Database

  author
Written By Andrew Jackson
Anuraag Singh
Approved By Anuraag Singh
Published On August 30th, 2016
Reading Time 5 Minutes Reading

Overview

As Exchange Server Database is mostly used in several organizations, employees need to exchange mails and file attachments related to work on a daily basis. Multiple emails are forwarded to different clients or senior officials, making the database size increase tremendously. Due to presence of repeated emails and the large-sized attachments, users and administrators of Exchange Server often faces problem associated to large mailbox database. Hence, it is necessary to figure out a solution for the same issue. In the blog, we will be discussing ways to remove attachments from Exchange Mailbox database that will help in reducing its size.

Need for Removal of Attachments

Increasing database size of Exchange server is one of the common problems faced by administrators because of unnecessary attachments that are of longer use. Types of attachments can be PDF, documents, uncompressed image or zip archive that consumes huge space. Issues related to large-sized database are higher chance of corruption, longer time to access the mails and need for storage size expansion. In order to avoid above issues, users need to remove attachments from Exchange Mailbox Database & manage the database size.

Multiple Ways to Remove Attachments

There are different methods to remove attachments from Exchange Mailbox Database depending on versions of Exchange Server:

Exchange 2003

In case of Exchange Server 2003, there are two ways for removing attachments.

1. Microsoft ExMerge Tool

It is a tool developed by Microsoft that can be availed free of cost from its official site. Before using this tool, we need to grant user account full mailbox rights to all mailboxes from where data needs to be extracted and the program should be run on system with Exchange 2003 administrative tools present. Following steps will be followed:

  • Launch the program after installation and click next until Procedure Selection option is shown.
  • Select Extract/Import, click on Next and define the name of server from where user wants to remove attachments.
  • Go to Options for Data Selection Criteria, set the following:
    In Data Tab, select user messages & folders
    Select Archive Data to Target store in Import Procedure section
    Enter the attachments name on Message Details Tab
  • Select Mailboxes to start scanning, specify the destination folder to save the extracted messages.
  • Choose Save the settings option and click on Next. All the messages with specific attachments will be deleted.

Note: Disadvantages are it removes attachments with messages and extracted data are saved in ANSI format-PST file with 2GB limit.

2. PowerShell Commands

It is mandatory to ensure that 32-bit version of Exchange 2007 management tools and MS Outlook 2003 SP2 or later are present before using PowerShell commands in Exchange 2003. User needs to have full access to all mailboxes.

User will use Export-Mailbox PowerShell command that is used to extract messages along with attachments from mailbox database to reduce it size. It involves commands like Get-Mailbox to pipe out results to Export-Mailbox containing all the mailboxes from the server specified. The following PowerShell command is used for removing attachments:

1

After executing the command given above, all the messages with PDF attachments will be removed from the mailbox database and it will be stored in Extract. pst file residing on D: drive. Similar to the method using ExMerge Tool, this PowerShell command will also remove all the messages and attachments completely from Exchange database.

Exchange 2007

As we have observed that Export-Mailbox PowerShell command will be used to extract all the messages with attachments to reduce the size. In order to use the command properly, User need to ensure the presence of following setup:

  • A machine having 32-bit version of Exchange 2007 management tools & MS Outlook 2003 SP2 or later installed
  • Users with the Exchange Server Administrator Role and membership of local Administrators group
  • User needs to make sure that he/she has full access to all the mailboxes.

The same command that was stated in above section of Exchange 2003 will be used in Exchange 2007 that is:

2

Running this command will remove all the messages with PDF attachments from the mailbox database and store them locally at the user’s system. This method will also remove mails as well as the attachments associated with it.

Exchange 2010/2013/2016

User will take the help of PowerShell Command to remove attachments from Exchange server database 2010, 2013 or 2016 using New-MailboxExportRequest. The plus point of using this method is it does not require to be executed on the system with 32-bit version of the Exchange Management tools. For using the command, user will launch it directly on Exchange 2010, 2013 or 2016 server. The only mandatory requirement for the smooth functioning of the command is to grant the right/ permissions to export mailboxes to particular user (administrator).

The following command will be used to grant permissions:

3

In addition to this, user needs to create shared folder on the selected server and Exchange Trusted Subsystem Read or write permission needs to be granted. In the below example, the folder named ShareFolder1 on the SERVER01 will be used. The following syntax will be used to export the attachments:

4

Running the above command will copy all the messages with PDF type attachments to the Attachments1.pst located at ShareFolder1 on SERVER01 machine. New-MailboxExportRequest is different from Export-Mailbox, as it does not provide functionality to remove attachments from database, which was available in Export-Mailbox command.

Conclusion

As the number of attachments associated with the emails in Exchange Server increases, the database file can be corrupted and user may have problem in accessing it. That is why; removal of attachments regularly is needed to ensure that the size of mailbox is managed properly. The blog has discussed several ways to remove attachments from Exchange mailbox database for many Exchange versions. It explains the usage of ExMerge Tool for the same purpose as well as PowerShell Commands. Since EXMerge Tool will save the PST file in ANSI format only with 2GB limit, PowerShell commands is better as it saves the attachments in UNICODE format without any size limit.

  author

By Andrew Jackson

I am SQL DBA and SQL Server blogger too. I like to share about SQL Server and the problems related to it as well as their solution and also I do handle database related user queries, server or database maintenance, database management, etc. I love to share my knowledge with SQL Geeks.