PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Interoperability
Problem with AdvancedSearchComplete and with Sort function limitation
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Interoperability
Problem with AdvancedSearchComplete and with Sort function limitation
![]() |
Problem with AdvancedSearchComplete and with Sort function limitation |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I am writing a C# library to receive numbers from a different
application, look up the Contact name from Contacts folder and then display mails from that person. I am trying to use AdvancedSearch for name matching but facing problems with C#. The reason I need AdvancedSearch is that Restrict and Find do not have any wildcard characters and I need to take care of multiple possibilities like say for Bill Gates it could be "Bill Gates" "Gates, Bill" "Gates, Bill (IT)" "Gates, Bill (HR)" "Bill Gates (IT)" "Bill Gates (HR)" I was thinking of wildcard characters for sFilter = "[SenderName] = 'Gates, Bill (??)'" But I learn that wildcard characters are not supported with Restrict. Now, 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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
FYI, "interop" in this newsgroup means interoperability with other programs,
not COM interop. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "piyush" <agarwalpiyushk@yahoo.co.in> wrote in message news:795b682f.0407011257.4305abfe@posting.google.com... > I am writing a C# library to receive numbers from a different > application, look up the Contact name from Contacts folder and then > display mails from that person. > > I am trying to use AdvancedSearch for name matching but facing > problems with C#. The reason I need AdvancedSearch is that Restrict > and Find do not have any wildcard characters and I need to take care > of multiple possibilities like say for Bill Gates it could be > > "Bill Gates" > "Gates, Bill" > "Gates, Bill (IT)" > "Gates, Bill (HR)" > "Bill Gates (IT)" > "Bill Gates (HR)" > > I was thinking of wildcard characters for > sFilter = "[SenderName] = 'Gates, Bill (??)'" > > But I learn that wildcard characters are not supported with Restrict. > > Now, 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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

