• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1759
  • Last Modified:

Are Outlook read receipts considered Outlook.MailItems?

I'm trying to construct a .pst file from a bunch of .msg files. when I try to process an Outlook read-receipt this line of code:

oMail = ((Outlook.MailItem)oOutlook.Session.OpenSharedItem("c:\111234.msg"));

throws this error:

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.MailItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063034-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
0
Bob Hoffman
Asked:
Bob Hoffman
  • 3
  • 2
2 Solutions
 
mvidasCommented:
Hi HB,

I believe read receipts are considered a Outlook.ReportItem rather than MailItem.

Matt
0
 
Helen FeddemaCommented:
mvidas is probably correct.  At any rate, I am sure they are not MailItems.  To find out exactly, you could write some code to iterate through the items in the Inbox (or another folder), and report their Subject (so you know which message is which) and Class properties to the Immediate Window.  Check the OlObjectClass enum to match up the number with the named Class constant.
0
 
Bob HoffmanDeveloperAuthor Commented:
It doesn't appear to be a ReportItem, it fails with the same error when I try to cast it as a ReportItem.

Helen.. that's a good idea, I'll write a little program to check the type of similar items in my own inbox.  

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mvidasCommented:
Odd.. I used VBA in outlook with the following code when on a read receipt:

Sub Hmm()
  MsgBox TypeName(Application.ActiveExplorer.Selection.Item(1))
End Sub

And it shows ReportItem. Not sure why your code doesn't like it though.
0
 
Bob HoffmanDeveloperAuthor Commented:
mvidas was correct they are ReportItems. When I casted it as a MailItem if failed, I then tried casting it aa ReportItem it also failed (with the same incorrect type error). Turns out the first cast put a lock on the file, (not sure why).. the fix was to run the gargabe collector prior to casting it a second time as a ReportItem. Thanks for the help everyone.
0
 
mvidasCommented:
Glad to help! I'm going to post your final resolution comment here, as others can't see it. Let us know if you need anything else!

Author Comments:
mvidas was correct they are ReportItems. When I casted it as a MailItem if failed, I then tried casting it aa ReportItem it also failed (with the same incorrect type error). Turns out the first cast put a lock on the file, (not sure why).. the fix was to run the gargabe collector prior to casting it a second time as a ReportItem. Thanks for the help everyone.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now