i am using a recurisive loop that counts all items in the folders. when it completes, i would like it to give me a total count.
i have the code segments to use this (above), however when i write to my output log file, the output is formatted how i want.
my log will look like this:
name of store: 0
Total items in store: 0
folder1: 67
Total items in store: 67
folder2: 21
Total items in store: 88
Total items in store: 88
Total items in store: 88
I know i need some type of if statement to allow writing of the total combined count to the log file, however i am out of ideas of how to create this...
i would like the log file to look like this:
name of store: 0
folder1: 67
folder2: 21
Total items in store: 88
any suggestions?
Code:
Sub ProcessFolder(ByRef StartFolder As Microsoft.Office.Interop.Outlook.MAPIFolder, ByRef RootFolder As Microsoft.Office.Interop.Outlook.MAPIFolder)
Dim objFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim objRootFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim objItem As Object
On Error Resume Next
intCount = intCount + StartFolder.Items.Count
objRootFolder = RootFolder
For Each objFolder In StartFolder.Folders
writeLog(objFolder.Name.ToString & ": " & objFolder.Items.Count)
Call ProcessFolder(objFolder, objRootFolder)
Next objFolder
objFolder = Nothing
If objRootFolder.Name = "" Then
writeLog("Total Items in Mailbox: " & intCount)
End If
End Sub
Sub writeLog(ByVal strText As String)
Dim sPath As String = "C:\CountItemLog.txt"
Dim LogFileStream As New IO.FileStream(sPath, IO.FileMode.Append, IO.FileAccess.Write)
Dim LogStreamWriter As New IO.StreamWriter(LogFileStream)
LogStreamWriter.WriteLine(strText)
LogStreamWriter.Close()
End Sub
i have the code segments to use this (above), however when i write to my output log file, the output is formatted how i want.
my log will look like this:
name of store: 0
Total items in store: 0
folder1: 67
Total items in store: 67
folder2: 21
Total items in store: 88
Total items in store: 88
Total items in store: 88
I know i need some type of if statement to allow writing of the total combined count to the log file, however i am out of ideas of how to create this...
i would like the log file to look like this:
name of store: 0
folder1: 67
folder2: 21
Total items in store: 88
any suggestions?