Summarizing personal folders

  • Thread starter Thread starter DKS
  • Start date Start date
D

DKS

Hi,

How could I easily scan my personal folder and generate a list (table of
contents) of the mails found in there. i would prefer the following
information:

date of mail
from whom did the mail originate
Subject of the mail
Is there an attachment (yes or no)

The output list can be in .txt or .csv format.

Many TIA.
 
You are asking for a fair bit here, and I don't really have the time to write
a full application. The code below should get you started, just replace the
Debug.Print line with file output code . Run the 'ScanAllFolders' macro.
This in turn calls the 'ScanFolder' sub, which recursively calls itself.:-

Public Sub ScanAllFolders()
Dim objFolder As MAPIFolder
Dim lngItems As Long
Dim lngCounter As Long
Set objFolder =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent
Call ScanFolder(objFolder)
Set objFolder = Nothing
End Sub
Private Sub ScanFolder(objMAPIFolder As MAPIFolder)
Dim lngItems As Long
Dim lngCounter As Long
Dim objMailItem As MailItem
Dim objFolder As MAPIFolder
For Each objFolder In objMAPIFolder.Folders
Call ScanFolder(objFolder)
Next
For lngCounter = 1 To objMAPIFolder.Items.Count
If TypeName(objMAPIFolder.Items(lngCounter)) = "MailItem" Then
Set objMailItem = objMAPIFolder.Items(lngCounter)
Debug.Print objMailItem.ReceivedTime, objMailItem.SentOn,
objMailItem.To, objMailItem.SenderEmailAddress, objMailItem.Attachments.Count
Set objMailItem = Nothing
End If
Next
End Sub
 
Alan,

don't worry about the generating output part (I can manage that). I am weak
with knowing how to manipulate Outlook and if your solution helps me there
then the writing part will be managed elsewhere.

Thanks
 
Back
Top