InfiniTec - Henning Krauses Blog

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

Recover deleted elements from an Exchange 2000/2003 folder

More Information

Outlook and Exchange know two ways how to delete a file: A soft-delete, which is performed when you simply press delete on an item. The affected item is then moved to the recycle-bin. The other method is called hard-deletion. These items are kept in the store for a configurable duration, typically 30 days.
To check if there are any deleted items or folders within a given public or private folder, you can read the values of these properties:

  • PR_DELETED_MSG_COUNT
    This property contains the number of deleted messages in the folder
  • PR_DELETED_FOLDER_COUNT
    This property contains the number of deleted folders in the folder

To enumerate the deleted items, a SEARCH command is issued on the folder:

    1 SEARCH /public/folder / HTTP/1.1

    2 Host: www.contoso.com

    3 Depth: 0

    4 Content-type: text/xml;

    5 Content-Length: XXXXX

    6 

    7 <?xml version="1.0"?>

    8 <a:searchrequest xmlns:a="DAV:">

    9   <a:sql>

   10     SELECT “DAV:displayname", "DAV:contentclass", "DAV:getcontentlength", "DAV:href", "DAV:isfolder" FROM SCOPE('SOFTDELETED TRAVERSAL OF "http://www.contoso.com/public/folder"')

   11   </a:sql>

   12 </a:searchrequest>

To recover one or more of these items, a BCOPY command is issued:

    1 BCOPY /public/container/ HTTP/1.1

    2 Host: www.contoso.com

    3 Depth: 0

    4 Content-type: text/xml;

    5 Content-Length: XXXXX

    6 

    7 <?xml version="1.0"?>

    8 <a:copy xmlns:a="DAV:">

    9   <a:target>

   10     <a:href>http://www.contoso.com/public/folder-softdeleted-/-FlatUrlSpace-/93c5676ddb37ee4690b4756339818e46-6d89</a:href>

   11     <a:dest>http://www.contoso.com/public/folder/recovereditem</a:dest>

   12   </a:target>

   13 </a:copy>

After the item has been recovered, the deleted element can safely be removed from the store via the BDELETE command:

    1 BDELETE /public/container/ HTTP/1.1

    2 Host: www.contoso.com

    3 Depth: 0

    4 Content-type: text/xml;

    5 Content-Length: XXXXX

    6 

    7 <?xml version="1.0" encoding="UTF-8"?>

    8 <a:delete xmlns:a="DAV:">

    9   <a:target>

   10     <a:href>http://www.contoso.com/public/folder/-softdeleted-/-FlatUrlSpace-/93c5676ddb37ee4690b4756339818e46-6d89</a:href>

   11   </a:target>

   12 </a:delete>


Technorati:

Posted by Henning Krause on Monday, February 7, 2005 12:00 AM, last modified on Monday, December 26, 2005 12:00 PM
Permalink | Post RSSRSS comment feed