Handling Meeting requests in inbox with vb.net & vsto

mm72
mm72 used Ask the Experts™
on
I have a routine that iterates through a users inbox and carries out various transactions on each email. This is all working fine. However if a user has a meeting request in the inbox the routine falls over. Can someone reccomend a way of handling this as i want to ignore the meeting requests.

many thanks


Dim inbox As MAPIFolder = Me.Application.ActiveExplorer().Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
            Dim items As Outlook.Items = inbox.Items 
 
           
 
            For Each mi As MailItem In items
 
Do stuff
 
next

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I could be wrong here, and don't have the right system in front of me to test, but I believe even though in the inbox, meeting requests are actually still of type AppointmentItem, not MailItem.
Have you tried using the OfType on items?

For Each mi As MailItem In items.OfType(Outlook.MailItem)
Most Valuable Expert 2012
Top Expert 2014
Commented:
You may try to change the loop to the following

For i as integer = 1 to Items.count
      If TypeOf(Items(i)) Is MalItem Then
         'rest of the code here
      End If
Next
Commented:
Thanks for the suggestions above in the end i achieved what i needed by examining the message class if the messageclass was "IPN.Note" then i processed the item otherwise it was ignored.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial