![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hey all, I receive the following error when I try to iterate through and
access emails and their associated attachments: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook._MailItem'. I will demonstrate the 3 main attempts (of the trillion I've tried). :-/ Attempt #1: oOutlook = new Outlook.Application(); oNs = oOutlook.GetNamespace("MAPI"); oFldr = oNs.Folders["Public Folders"].Folders["Test"] foreach (MailItem oMessage in oFldr.Items) { .... } Attempt #2: oOutlook = new Outlook.Application(); oNs = oOutlook.GetNamespace("MAPI"); oFldr = oNs.Folders["Public Folders"].Folders["Test"] foreach (Object oMessage in oFldr.Items) { .... } Attempt #3: oOutlook = new Outlook.Application(); oNs = oOutlook.GetNamespace("MAPI"); oFldr = oNs.Folders["Public Folders"].Folders["Test"] for (int i = 1; i = oFldr.Items.Count; i++) { Object o = oFldr.Items[i]; Type t = o.GetType(); } I know that people are wont to send in email types other than MailItem. For instance, there are several "discussion" items in the email box in question. I've tried to isolate those, but when I run #3, I find that "oFldr.Items[i]" has a type of "System.__ComObject" which is unhelpful to me. All I'm trying to do is grab email messages and discussion items and process them. Unfortunately, it bombs out. Help! |
#2
|
|||
|
|||
![]()
The main issue here is I'm unable to reach the mail items and discussion
items. I just can't. Any example code would be helpful. |
#3
|
|||
|
|||
![]()
Are you sure you really have a MailItem object?
You could also have ReportItem, ContactItem, etc. -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Emrak" wrote in message ...[i] Hey all, I receive the following error when I try to iterate through and access emails and their associated attachments: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook._MailItem'. I will demonstrate the 3 main attempts (of the trillion I've tried). :-/ Attempt #1: oOutlook = new Outlook.Application(); oNs = oOutlook.GetNamespace("MAPI"); oFldr = oNs.Folders["Public Folders"].Folders["Test"] foreach (MailItem oMessage in oFldr.Items) { ... } Attempt #2: oOutlook = new Outlook.Application(); oNs = oOutlook.GetNamespace("MAPI"); oFldr = oNs.Folders["Public Folders"].Folders["Test"] foreach (Object oMessage in oFldr.Items) { ... } Attempt #3: oOutlook = new Outlook.Application(); oNs = oOutlook.GetNamespace("MAPI"); oFldr = oNs.Folders["Public Folders"].Folders["Test"] for (int i = 1; i = oFldr.Items.Count; i++) { Object o = oFldr.Items[i]; Type t = o.GetType(); } I know that people are wont to send in email types other than MailItem. For instance, there are several "discussion" items in the email box in question. I've tried to isolate those, but when I run #3, I find that "oFldr.Items" has a type of "System.__ComObject" which is unhelpful to me. All I'm trying to do is grab email messages and discussion items and process them. Unfortunately, it bombs out. Help! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Request using XML HTTP object throws "Access is Denied" error | Sangeeta[_2_] | Outlook and VBA | 0 | February 11th 09 10:30 AM |
Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass' | John Yovas | Add-ins for Outlook | 2 | September 12th 08 04:23 PM |
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. | Dhananjay | Outlook and VBA | 3 | October 13th 07 07:56 AM |
Unable to reply "null or not an object" | Dave | Outlook Express | 1 | November 13th 06 07:04 PM |
“The operation failed. An object could not be found. Unable to..." | Milton | Outlook - Calandaring | 0 | August 3rd 06 04:07 PM |