Problem with AdvancedSearchComplete and C#. Also, ItemsCollection Sort

P

piyush

I am trying to use AdvancedSearch but facing problems with C#.

Where should the AdvancedSearchComplete code be put ? Should it be a
function
in itself ? If so, what should be its name (in VBA, I saw
Application_AdvancedSearchComplete or
outlookobj_AdvancedSearchComplete in Randy Bryne's book).

Also, does urn:schemas:inbox:SenderName exist for me to search on
SenderName?

My code is as follows :

class blah {

private Outlook.ApplicationClass ola ;
private Outlook.Namespace olns

blah() //constructor
{
// all this constructor work is perfect
olns = ola.GetNamespace ;
.... (all these things seem to be fine)
}

public void func1()
{
Outlook.Search olsearch;
ola.Application.AdvancedSearch ("Inbox", "urn:schemas:inbox:SenderName
LIKE '%Bill%'", false, "complete")
}

public void AdvancedSearchComplete(Outlook.Search olsearch)
{
olresults = olsearch.Results;
for (int i = 1 ; i < olresults.Count ; i++)
{
Outlook._MailItem tempItem = (Outlook._MailItem)olresults.Item (i);
Console.Writeline (tempItem.Subject);
}
}//AdvancedSearchComplete
}//class

Obviously this doesnt work.

A different way to solve my problem is :

I have defined 3 search filters that cover all the cases matching the
SenderName (hence no need of wild characters and hence no need of
AdvancedSearch).

The problem is each of them is a different Restrict and hence each of
them is a differnet Items collection (ie)

"Bill Gates" returns results (in some random order apparently) in
colitems1
"Gates, Bill" returns results (in some random order apparently) in
colitems2

What I want to do is to sort the results and display the mails (from
either of the display names). For that I would need to have all the
items in a single collection (to sort them).

Any comments are highly appreciated.

Thanks !
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