elquixiote
Technical User
Hi!. I'm develping an application to read the inbox messages in outlook.
Up to now all is ok, but, (there always a but) I'm
getting a type mismatch error when the application reads
a declination response message. If I delete it from the inbox my application continues reading the messages.
Can some body tell me what's happening ?
Of course, I could trapp the error and resume, (I'm not interested in declination messages) but I'd like to understand whats wrong.
My code is as follows:
Dim objoutlook As Outlook.application
Dim myfolder As Outlook.MAPIFolder
Dim myitem As Outlook.MailItem
Set objoutlook = CreateObject("Outlook.application")
Set nms = objoutlook.GetNamespace("MAPI")
Set myfolder = nms.GetDefaultFolder(olFolderInbox)
Text1.Text = ""
For i = 1 To myfolder.Items.Count
' I got a type mismatch error in the following line
' when the message is declination response
Set myitem = myfolder.Items(i)
Text1.Text = Text1.Text & myitem.To & "//" & myitem.Subject & vbCrLf
Next i
Text2.Text = myitem.Body
Thanks
El Quijote
Up to now all is ok, but, (there always a but) I'm
getting a type mismatch error when the application reads
a declination response message. If I delete it from the inbox my application continues reading the messages.
Can some body tell me what's happening ?
Of course, I could trapp the error and resume, (I'm not interested in declination messages) but I'd like to understand whats wrong.
My code is as follows:
Dim objoutlook As Outlook.application
Dim myfolder As Outlook.MAPIFolder
Dim myitem As Outlook.MailItem
Set objoutlook = CreateObject("Outlook.application")
Set nms = objoutlook.GetNamespace("MAPI")
Set myfolder = nms.GetDefaultFolder(olFolderInbox)
Text1.Text = ""
For i = 1 To myfolder.Items.Count
' I got a type mismatch error in the following line
' when the message is declination response
Set myitem = myfolder.Items(i)
Text1.Text = Text1.Text & myitem.To & "//" & myitem.Subject & vbCrLf
Next i
Text2.Text = myitem.Body
Thanks
El Quijote