With a message filter you'd just add the field's property tag and the value
you want to search for:
MAPI.Field oField = (MAPI.Field)fields.Add
(MAPI.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER,"111111");
You also may have other problems since the use of CDO 12.1 is not supported
in .NET code.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All,
>
> All i am trying to is look for a particular Telephone number in
> Contacts using MessageFilter instead of going through each message in
> Contacts to speed up the search process. Can anyone help me in how to
> do this.
> Preferrably in c# but vb will also do.
>
> This is how my code looks like
> MAPI._Session oSession = new MAPI.Session();
> Object vEmpty = Missing.Value;
> oSession.Logon(vEmpty,vEmpty,false,false,vEmpty,vEmpty,vEmpty);
> MAPI.Folder oFolder = (MAPI.Folder)oSession.GetDefaultFolder(5);
> MAPI.Messages oMessages = (MAPI.Messages)oFolder.Messages;
> MAPI.MessageFilter oFilter = (MAPI.MessageFilter)oMessages.Filter;
> MAPI.Fields fields = (MAPI.Fields)oFilter.Fields;
> MAPI.Field oField =
> (MAPI.Field)fields.Add(MAPI.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER,vEmpty,"111111",vEmpty);
> for (int i = 1; i < Convert.ToInt32(oMessages.Count); i ++)
> {
> MAPI.Message oMessage = (MAPI.Message)oMessages.get_Item(i);
> MAPI.Fields oFields = (MAPI.Fields)oMessage.Fields;
> MAPI.Field oField1 = (MAPI.Field)oFields.get_Item
> (MAPI.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER,vEmpty);
> object obj = oField1.Value;
> }
> oSession.Logoff();
>
> This For Loop goes through each of my messages in contacts. I was
> thinking it will loop only twice if i have two messages with the same
> number.
>
> Any help will be appreciated
>
> Regards Mita
>