I want to run through all my Outlook folders and build a Table of e-mails in each. But the code to add columns of e-mail properties to the table, such as:
Set oTable = oFolder.GetTable(sFilter)
oTable.Columns.Add ("SenderName")
fails on folders that don’t hold e-mails, such as the folder Calendar.
I could check if the first item in the folder is an e-mail by checking its class:
oFolder.Items.Item(1).class = olMail
But that cannot be a valid test because an e-mail folder can contain items that are not e-mails, such as a MeetingItem. If the first item in an e-mail folder happens to be a MeetingItem, then the above test would give a false negative on whether the folder is an e-mail folder.
So how can I test if a folder is an e-mail folder so I can know whether I can add e-mail properties to a table made from it?
>Solution :
You can use the Folder.DefaultItemType property which returns a constant from the OlItemType enumeration indicating the default Outlook item type contained in the folder.
Actually, Outlook folders may contain different type of items – mail, appointment, document, post and etc. The best what you could do is to check the default item type for the folder.