E
Emrak
Hey all, I receive the following error:
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;
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!
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;
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!