Problem with AdvancedSearchCompleteEvent Handler in C#

P

piyush

I am trying to use AdvancedSearch feature of Outlook 2003 and
processing the results from the search. I am not able to get this
piece of code running - please advice.

The event handler doesnt get called at all and an exception is raised.
The exception being thrown is "System.InvalidCastException".
Additional Information : No such interface supported.

public class blah {
private Outlook.ApplicationClass ola;
private Outlook.NameSpace olns;
private Outlook.MAPIFolder inboxFolder;

public blah () {
ola = new Outlook.ApplicationClass();
olns = ola.GetNameSpace ("MAPI");

// now add the event handler (myeventhandler)
ola.Session.Application.AdvancedSearchComplete += new
Outlook.ApplicationEvents_11_AdvancedSearchCompleteEventHandler(this.myeventhandler);
}

public void displayMails (String number_)
{
Outlook.Search olsearch. = ola.AdvancedSearch ("Contact",
"urn:schemas:contact:sn LIKE '%Bill%'", false, "complete");

...
}

void eventhandler (Outlook.Search olsearch)
{
...
}

I dont have a very good understanding of the events but has it
something got to with having System.EventArgs specified somewhere ..
if so where ?

Thanks in advance !
Piyush
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top