Reading exchange emails using outlook automation

C

Clifford Zivi

I am trying to read emails using outlook automation on an exchange server. I
am able to read the emails fine until I come across one that was returned to
me as "undeliverable". Every time my program finds one I get an error #13 ,
type missmatch. My code is as follows:

Dim loOutlook As Outlook.Application
Dim LoNameSpace As Outlook.NameSpace
Dim olFolderInBox As Variant
Dim loInbox As Object
Dim loMess As Outlook.MailItem

olFolderInBox = 6
' open the inbox folder
Set loOutlook = CreateObject("Outlook.Application")
Set LoNameSpace = loOutlook.GetNamespace("MAPI")
Set loInbox = LoNameSpace.GetDefaultFolder(olFolderInBox)

Set loMess = loInbox.Items.GetFirst()
' Now we have the first message in the InBox

' go through all the messages looking for the ones we want
For Each loMess In loInbox.Items
MsgBox loMess.SenderName
MsgBox loMess.Subject
Next

It shows the SenderName and Subject fine until it hits a "Undeliverable"
message. Any ideas???
 

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

Top