VB.Net Outlook Iterate though items in Folder

  • Thread starter Thread starter Rogoflap
  • Start date Start date
R

Rogoflap

I have a loop that loops though each message in a Outlook
folder... Outlook 2003/ VB.Net 2003/ XP operating system.
Exchange 5.5

Dim myOlapp As Outlook.Application
Dim myoMsg As Outlook.MailItem
Dim myOFolder As Outlook.MAPIFolder

myOlapp = CreateObject("Outlook.Application")
myoMsg = myOlapp.CreateItem
(Outlook.OlItemType.olMailItem)
myOFolder = GetFolder(sInboxMailFolder)
for each myomsg in myOfolder.items
If myoMsg.Attachments.Count > 0 Then
....
......
end if
next message.

My probem is that sometimes there are other types of
messages in there (Hidden, contacts etc).

I would like to see the type first then do something with
it.

What is the best way to do this.

Thanks,

Rog
 
Dim myoMsg as Object to force late binding and check the myoMsg.Class
property in the loop. For the regular mail messages, Class is 43.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top