PC Review


Reply
Thread Tools Rate Thread

WebDav WHERE Clause not finding mobile, telephoneNumber2 in AdvancedSearch()

 
 
dangordo@gmail.com
Guest
Posts: n/a
 
      16th Nov 2006
Hello -- I'm running an AdvancedSearch() of Outlook contacts using C#,
and I'm having a problem with the filter parameter (essentially a
WebDAV WHERE clause). The following code works well, except that I get
no results when searching on certain fields (mobile, telephoneNumber2;
see below). Can anyone help?

using System;
using System.Collections;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace GetNickname3
{
public static class OutlookSearch
{
//right now, just display all names
public static void findContacts(string phoneNumberToFind)
{
//open outlook and contacts folder
Outlook._Application olApp = new
Outlook.ApplicationClass();
Outlook._NameSpace olNS = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder contacts =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

//set advanced search events
olApp.Session.Application.AdvancedSearchComplete += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_AdvancedSearchCompleteEventHandler(OnCompleteAdvanacedSearch);
//start search
startAdvancedSearch(olApp);

Console.ReadLine();
}

private static void startAdvancedSearch(Outlook._Application
olApp)
{
Outlook.Search s;
try
{
//set filter string
string filterStr = "";
filterStr = "urn:schemas:contacts:telephoneNumber like
'%212%'"; //works
filterStr = "urn:schemas:contactsager like '%212%'";
//works
filterStr = "urn:schemas:contacts:homePhone like
'%212%'"; //works
filterStr =
"urn:schemas:contacts:facsimiletelephonenumber like '%212%'"; //works
//filterStr = "urn:schemas:contacts:telephoneNumber2
like '%212%'"; //doesn't work
//filterStr = "urn:schemas:contacts:telephonenumber2
like '%212%'"; //doesn't work
//filterStr = "urn:schemas:contacts:mobile like
'%212%'"; //doesn't work

//start advanced search
s = olApp.AdvancedSearch("Contacts", filterStr, false,
"ContactsSearch");

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.Data);
Console.WriteLine(ex.Source);
}
}

private static void OnCompleteAdvanacedSearch(Outlook.Search s)
{
Console.WriteLine("Complete");
Console.WriteLine(s.Results.Count);
foreach (object obj in s.Results)
{
if (obj is Outlook.ContactItem)
{
Outlook.ContactItem myCI =
(Outlook.ContactItem)obj;
Console.WriteLine(myCI.LastName + ", " +
myCI.FirstName + ": " + myCI.MobileTelephoneNumber);
}
}
}
}
}

 
Reply With Quote
 
 
 
 
Brian Tillman
Guest
Posts: n/a
 
      17th Nov 2006
(E-Mail Removed) <(E-Mail Removed)> wrote:

> Hello -- I'm running an AdvancedSearch() of Outlook contacts using C#,


Try asking in a programming newsgroup like
news://msnews.microsoft.com/microsof...ic.program_vba or
news://msnews.microsoft.com/microsof...program_addins
--
Brian Tillman

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WebDAV (mini-redirector): double-click in an SSL-enabled WebDAV-folder to open an Office 2003 file does not work Rudolf Kaertner Windows Vista General Discussion 2 12th Mar 2009 05:42 PM
Can I use a between clause or in clause on an IF statement =?Utf-8?B?c3NjaWFycmlubw==?= Microsoft Excel Programming 2 4th May 2007 04:48 PM
Is WebDAV the same as or a subset of FTP features ? Detecting if ftp server has WebDAV option ? Ken Philips Windows XP Help 1 22nd Mar 2007 03:17 PM
Is WebDAV the same as or a subset of FTP features ? Detecting if ftp server has WebDAV option ? Ken Philips Windows XP Networking 2 22nd Mar 2007 03:17 PM
Trying to do a between clause with webdav code =?Utf-8?B?QmluaCBQaHVuZw==?= Microsoft Dot NET 0 10th Nov 2005 01:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:47 AM.