InfiniTec - Henning Krauses Blog

Don't adjust your mind - it's reality that is malfunctioning

Retrieve the size of a Microsoft Exchange 2000/2003 public folder

More Information

The size of all messages in a folder is stored on each folder object. This information can be extracted from several fields, for example the property. But this property seems to be mapped to the MAPI property PR_MESSAGE_SIZE. The drawback with this property is, that it is limited to 32 bit, so it works only for folders containing not more than 4 GB.
Luckily, this property is also available as a 64 bit value, stored in the MAPI property PR_MESSAGE_SIZE_EXTENDED


The following Visual Basic script shows how to use the above mentioned property:

    1 option explicit

    2 dim xmlhttp

    3 dim xmldoc

    4 dim strrequest

    5 dim ie


    7 strrequest = "<?xml version=""1.0"" ?><D:propfind xmlns:D=""DAV:"" xmlns:E=""""><D:prop><E:x0e080014 /></D:prop></D:propfind>"

    8 Set xmlhttp = CreateObject("msxml2.xmlhttp")

    9 Set xmldoc = CreateObject("Msxml2.DOMDocument")

   10 xmldoc.loadXML(strrequest)


   12 wscript.echo "Connecting to " & wscript.Arguments(0) & "..."

   13 xmlhttp.Open "PROPFIND", wscript.Arguments(0), false, wscript.Arguments(1), wscript.arguments(2)

   14 xmlhttp.setRequestHeader "Content-type:", "text/xml"

   15 xmlhttp.setRequestHeader "Depth", "0"

   16 xmlhttp.send strrequest

   17 wscript.echo "Return status: " & xmlhttp.status & " " & xmlhttp.statustext


   19 set xmldoc = xmlhttp.responseXml

   20 if (xmlhttp.status = 207) then

   21     xmldoc.setProperty "SelectionNamespaces", "xmlns:ex=''"

   22     wscript.echo "Size of folder: " & xmldoc.selectSingleNode("//ex:x0e080014").text & " Bytes"

   23 end if

To use this script, simply copy it into a text file and save it as foldersize.vbs file. Then open a command prompt and type the following:

    1 cscript foldersize.vbs http://myserver/public/myfolder username password

Where myserver is the exchange server that contains the folder you want to check and myfolder ist the name of the folder.

More Information

This script can also be run against a folder withing a mailbox of a user. To do this, open a command prompt and type the following:

    1 cscript foldersize.vbs http://myserver/exchange/alias/myfolder username password

Where alias is the alias of the user's mailbox to check.


Posted by Henning Krause on Friday, December 31, 2004 12:00 AM, last modified on Monday, November 29, 2010 6:42 PM
Permalink | Post RSSRSS comment feed