T
Tom P.
I am trying to search an Outlook folder for certain e-mail items but I
am running into a problem getting items from the MAPIFolder object. I
use the following code but I can't find anything to cast the item to
that doesn't get an exception.
private List<SearchItem> SearchFolder(Outlook.MAPIFolder
CurrentFolder, string SearchString)
{
for (int iLoop = 1; iLoop < CurrentFolder.Items.Count;
iLoop++)
{
//This is where I get the exception
CurrentItem =
(Outlook.MailItemClass)CurrentFolder.Items[iLoop];
}
}
I've tried casting to MailItem, PostItem, Object, I've tried using
Folder.Items.GetFirst()... Nothing works. How do I get the item from
the MAPIFolder? Am I even supposed to be using the MAPIFolder?
I always get an exception: "Unable to cast COM object of type
'System.__ComObject' ........ failed due to the following error: No
such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."
I've looked up several code examples and none of them address this.
I'm using Microsoft.Office.Interop.Outlook v 11.0
Any help would be appreciated.
Tom P.
am running into a problem getting items from the MAPIFolder object. I
use the following code but I can't find anything to cast the item to
that doesn't get an exception.
private List<SearchItem> SearchFolder(Outlook.MAPIFolder
CurrentFolder, string SearchString)
{
for (int iLoop = 1; iLoop < CurrentFolder.Items.Count;
iLoop++)
{
//This is where I get the exception
CurrentItem =
(Outlook.MailItemClass)CurrentFolder.Items[iLoop];
}
}
I've tried casting to MailItem, PostItem, Object, I've tried using
Folder.Items.GetFirst()... Nothing works. How do I get the item from
the MAPIFolder? Am I even supposed to be using the MAPIFolder?
I always get an exception: "Unable to cast COM object of type
'System.__ComObject' ........ failed due to the following error: No
such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."
I've looked up several code examples and none of them address this.
I'm using Microsoft.Office.Interop.Outlook v 11.0
Any help would be appreciated.
Tom P.