Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Any way to get the statistics of a pst to a file.

Posted on 2007-09-29
Medium Priority
Last Modified: 2010-03-06

Any way to get the statistics of a pst to a file.
Outlook Pst files Stats to a file.(Txt file)
Question by:bsharath
  • 2
LVL 76

Expert Comment

by:David Lee
ID: 19988520
Hi, bsharath.

What statistics?
LVL 11

Author Comment

ID: 19988821
No of files in each folder.
Size of each folder.

LVL 76

Accepted Solution

David Lee earned 2000 total points
ID: 19994930
That's pretty simple.  Here's the macro code for doing this.  Follow these instructions to use this:

1.  Start Outlook.
2.  Click Tools->Macro->Visual Basic Editor.
3.  If not already expanded, expand Modules and click on Module1.
4.  Copy the code below and paste it into the right-hand pane of the VB Editor.
5.  Edit the code as needed.  I placed comment lines where things can, or need, to change.
6.  Click the diskette icon on the toolbar to save the changes.
7.  Close the VB Editor.
8.  Click Tools->Macro->Security.
9.  Change the Security Level setting to Medium.
10. Click on the folder you want to process.  The code will process that folder and all its subfolders.

Dim objFSO As Object, _
    objFile As Object

Sub GetFolderStats()
    Dim olkFolder As Outlook.MAPIFolder
    Set olkFolder = Application.ActiveExplorer.CurrentFolder
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Change the file name and path on the following line as desired.
    Set objFile = objFSO.CreateTextFile("C:\Folder Stats.txt", True)
    ProcessFolder olkFolder, 0
    Set objFile = Nothing
    Set objFSO = Nothing
    MsgBox "All done!"
End Sub

Sub ProcessFolder(objFolder As Outlook.MAPIFolder, intDepth As Integer)
    Dim olkSubFolder As Outlook.MAPIFolder, _
        olkItem As Object, _
        lngSize As Long
    For Each olkItem In objFolder.Items
        lngSize = lngSize + olkItem.Size
    objFile.WriteLine Space(intDepth * 2) & objFolder.Name & " (Items: " & objFolder.Items.Count & " Size: " & Format(lngSize, "###,###,###,##0") & ")"
    For Each olkSubFolder In objFolder.Folders
        ProcessFolder olkSubFolder, intDepth + 1
    Set olkItem = Nothing
    Set olkSubFolder = Nothing
End Sub


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
Upgrading from older Exchange server to the latest Exchange server can be tiresome, error-prone and risky, without being a seasoned exchange server administrators. It can become even problematic if you're an organization that runs on tight timeline…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question