VB and Outlook 2003 return items as mailitem

I wrote and addin for outlook 2003 and whenever my program hits a returned email and I try to open it as a mailitem it crashes my program.

What are returned emails if not a mailitem I can't seem to find a way to open those emails and parse them.



Answer this question

VB and Outlook 2003 return items as mailitem

  • Cute_Celina

    Indeed what you are getting is a ReportItem (http://msdn.microsoft.com/library/default.asp url=/library/en-us/vbaol11/html/olobjReportItem_HV05247366.asp)

    I'm not sure whether this object is exposed in the Office 2003 PIA or whether you need to use it at all. If you don't need it or you don't care about the contents, you can easily skip over "unwanted" items by doing something like this:

    If TypeOf Item Is MailItem Then
    ' Do your processing here
    End If

    I had a similar problem a couple of year ago because AppointmentItems were unexpectedly (to me) showing up in the Inbox, and I had incorrectly assumed that everything was a MailItem.

    Hope this helps,



  • flash.tato

    My addin works very well to parse all internal incoming emails, but some return emails are crashing it if I don't error trap and ignore those emails. I'm starting to think I need to use the MAPI-MIME API (vs2005) as (maybe) I'm getting a mime (oldstyle) email (object) returned back to the box.


  • LalitSRana

    I get a run time error 13 - type mismatch. I don't think that's my error trapping and doing MsgBox Err.Description, but the addin dying. This is VB professional too, it's not using the scripting VB, the addin after built is added into Outlook 2003 (current patches so past level 1 as recommended in the help files for vb2005) through "tools" menu, "options" menu choice, "other" tab, "advanced options" button, "Add-in manger" button.
  • ahmed921983

    Have you been able to catch exactly what the error is And is this in VBA (as opposed to VB) My experience with handling mail in Outlook is that Outlook is flaky at best at this sort of thing. In the end I wrote a class in "real" VB to handle all the stuff it needed to do, and then just call it from VBA in Outlook as required.

  • Eswans2000

    Abel:

    Thanks! I think that's going to do it for me.

    I was able to find http://msdn.microsoft.com/library/en-us/vbaol11/html/olobjItems_HV05247829.asp and that shows all the child objects, of which the appointment object that is mentioned is there too. This seems to list all the possible objects that can land in an inbox.

    Maybe it's just me but the MSDN library could be better organized, it seems to me it can be very difficult to find out what one doesn't know with the way it is layed out.


  • James Rea

    I get a run time error 13 - type mismatch. I don't think that's my error trapping and doing MsgBox Err.Description, but the addin dying.
  • EvilPenguin

    Sorry not "Add-in manger" button but the "Com Add-Ins" button for where the compiled Addin gets added to outlook 2003.
  • VB and Outlook 2003 return items as mailitem