All, I am attempting to export a listing of the contents of Exchange 2003 mailboxes to a CSV file. Specifically, I am trying to retrieve the folder path, subject, size, received time, sent time (optional), and message id (also optional) of each message in a user's mailbox.

I have this working in Exchange 2007 and above using the Exchange Web Services API, but this isn't applicable to 2003.

WebDAV is not enabled in the environment and I'm currently working to verify if POP3/IMAP is available. Assuming it isn't, is there another way to do this I'm missing?


You haven't provided much information about what access you have to the system or mailbox that you are trying to access. If you are the exchange admin for this server, it is probably easiest to add read access for you to the mailbox in question and use exmerge to make a copy of it to another account or if you happen to have Access installed as part of your Office suite, you can use "Get External Data" in Access to suck email in from Outlook, and the date field can be included. From Access you can dump the table into Excel (or csv) very simply.

Sadly, the exchange web services API does NOT work with exchange 2003 or SBS.

Since this is 2003 you are talking about, you could use WMI or powershell to do what you are thinking of.

Brian Desmond has a WMI script at his site that can pull this kind of information. This script will dump quite a bit of useful information about each mailbox on a particular server or set of servers to a CSV file which you can in turn import into Excel and create a spreadsheet from. I typically would import data into a SQL Server table using DTS (Data Transformation Services) if I needed to do alot of computation or data mining. Excel gets very slow when doing tasks that really require an index over a lot of data.

Note: The script uses WMI to get this information so Exchange 2003 is required. Only Exchange View Only level permissions are required in Active Directory, however you will likely need local Administrator privleges on each Exchange server. I don't have an Exchange 2003 server readily available to test and he was running as an Exchange Full Admin when he originally wrote this script. So use at your own risk! Taken from: http://briandesmond.com/blog/script-to-dump-exchange-mailbox-info-to-spreadsheet-csv/

' NAME   : Exchange Mailbox Stats Dumper
' AUTHOR : Brian Desmond, brian@briandesmond.com
' DATE   : 12/28/2005
' COMMENT: This script requires Exchange 2003. It will dump information
'           about each mailbox on the mailbox servers specified
'   Version     Date        Author          Note
'   -----------------------------------------------------------------
'   1.0         28Nov05     Brian Desmond   Initial Version
'   1.1         03Sep06     Brian Desmond   
'   1.2         13Dec08     Brian Desmond   Fixed array sizing bug,
'                                           Added error handling note
'                                           Added TODOs
'                                           Moved configurable items up
Option Explicit

' Note this script currently uses On Error Resume Next
' this isn't best practice - in reality this should be tightly 
' wrapped around the WMI connection logic in the loop rather
' than up here.
On Error Resume Next

' TODO: Configure this
' This is the total number of servers which you
' will specify for inventory

Dim strComputer()
ReDim strComputer(TOTAL_SERVERS)

' TODO: Populate this array
' Enter each server name below as an entry in the array
' starting with zero
strComputer(0) = "xmb01"
strComputer(1) = "xmb02"
strComputer(2) = "xmb03"


Dim objWMIService
Dim colItems

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim fil
Set fil = fso.CreateTextFile("mailboxes.txt")

Dim objItem
Dim line
Dim i

' Write a header row to the CSV
fil.WriteLine """Server"",""Storage Group"",""Mail Store"",""Mailbox GUID"",""Display Name"",""LegacyDN"",""Size"",""Item Count"",""Associated Content Count"",""Deleted Message Size"",""Date Absent"",""Storage Limit Level"""

For i = 0 To TOTAL_SERVERS - 1
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer(i) & _

    Set colItems = objWMIService.ExecQuery _
        ("Select * from Exchange_Mailbox")

    For Each objItem in colItems
        line = """" & objItem.ServerName & """"
        line = line & ","
        line = line & """" & objItem.StorageGroupName & """"
        line = line & ","
        line = line & """" & objItem.StoreName & """"
        line = line & ","
        line = line & """" & objItem.MailboxGUID & """"
        line = line & ","
        line = line & """" & objItem.MailboxDisplayName & """"    
        line = line & ","
        line = line & """" & objItem.LegacyDN & """"
        line = line & ","
        line = line & """" & objItem.Size & """"
        line = line & ","
        line = line & """" & objItem.TotalItems & """"
        line = line & ","
        line = line & """" & objItem.AssocContentCount & """"
        line = line & ","
        line = line & """" & objItem.DeletedMessageSizeExtended & """"
        line = line & ","
        line = line & """" & objItem.DateDiscoveredAbsentInDS & """"
        line = line & ","
        line = line & """" & objItem.StorageLimitInfo & """"

        fil.WriteLine line 
        'WScript.Echo line 

Set fso = Nothing
Set objWMIService = Nothing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.