• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

Need script to count messages in all outlook folders

Hi, we are doing a large scale mail migration from Scalix to online Exchange. I am running a migration tool which is workign well, however I need to verify that all mail was migrated in each users case. However, this is extremely tedious as many of the users have extremely deep folder structures inside of outlook and clicking through each one is not realistic.

What I would like is a script which can scan a local outlook profile (I have credentials for each user and can create a local mail profile for each one), and pull a list of folders, and the number of messages in each folder into Excel. From this, I will be able to compare with my migration results to ensure the number of messages match up. If there are cases where messages were missed, it will be easy for me to see and dig deeper.

I'm also not very well versed in scripting, so if you could include instructions on how exactly I would run the script, this would be appreciated.

If you need any further information, please let me know.

Thanks.
0
subversive99
Asked:
subversive99
  • 2
  • 2
1 Solution
 
hitsdoshi1Commented:
There you go...
Set olApp = CreateObject("Outlook.Application")
Set olns = olApp.GetNameSpace("MAPI")
    For icnt = 1 To olns.Folders.Count
            Set Folder = olns.Folders.Item(icnt)
            msgbox Folder.Items.Count
    Next

Open in new window

0
 
JonMnyCommented:
If you have subfolders will need to be recursive


Dim olns
Set olApp = CreateObject("Outlook.Application")
Set olns = olApp.GetNameSpace("MAPI")


dim filesys, filetxt, getname, path 
Set filesys = CreateObject("Scripting.FileSystemObject") 
Set filetxt = filesys.CreateTextFile("f:\outlook.csv", True) 
folderinfo(olns.folders)
filetxt.Close 
msgbox "finished"
Function  folderinfo(folders)
for each folder in folders    
filetxt.WriteLine("Folder '" & Folder.Name & "," &  Folder.Items.Count &  "," & folder.parent )

	folderinfo(folder.folders)
    Next
   
   
End Function

Open in new window

0
 
subversive99Author Commented:
Hi Jonmny, thanks this looks promising. Can you give me a quick walk through on how to run it?

Also, does there need to be only one outlook profile on the system, or will this allow me to select which profile to scan? Thanks.
0
 
subversive99Author Commented:
Works like a charm, thanks!
0
 
JonMnyCommented:
this is just a vbscript file, if you copy to a textfile and give it the extension of .vbs it will run.

you will want to change line 8 to a valid path for  your system

Set filetxt = filesys.CreateTextFile("f:\outlook.csv", True)

I only have one profile on my machine so I cant test this but If you use the modified code below It should use the selected profile


Dim olns
Set olApp = CreateObject("Outlook.Application")
Set olns = olApp.GetNameSpace("MAPI")
profile=inputbox ("Input Profile" )
olns.Logon profile
dim filesys, filetxt, getname, path 
Set filesys = CreateObject("Scripting.FileSystemObject") 
Set filetxt = filesys.CreateTextFile("f:\outlook.csv", True) 
folderinfo(olns.folders)
filetxt.Close 
msgbox "finished"
Function  folderinfo(folders)
for each folder in folders    
filetxt.WriteLine("Folder '" & Folder.Name & "," &  Folder.Items.Count &  "," & folder.parent )

	folderinfo(folder.folders)
    Next
   
   
End Function

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now