PC Review


Reply
Thread Tools Rate Thread

CDO, Look for a Telephone Number using MessageFilter

 
 
mgarg@syssol.com.au
Guest
Posts: n/a
 
      29th Aug 2005
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

 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      29th Aug 2005
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
>


 
Reply With Quote
 
 
 
 
mgarg@syssol.com.au
Guest
Posts: n/a
 
      30th Aug 2005
But using this line in .Net

MAPI.Field oField =
(MAPI.Field)fields.Add(MAPI.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER,"92");

Gives me a compile Error
No overload for method 'Add' takes '2' arguments

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      30th Aug 2005
As I said, use of CDO 1.21 is not supported in .NET code. When I create a
CDO message filter I only use the 2 arguments and it's always worked. The
filtering examples at www.cdolive.com also only use 2 arguments and you
can't argue with Sig Weber's code for CDO.

--
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)...
> But using this line in .Net
>
> MAPI.Field oField =
> (MAPI.Field)fields.Add(MAPI.CdoPropTags.CdoPR_BUSINESS_TELEPHONE_NUMBER,"92");
>
> Gives me a compile Error
> No overload for method 'Add' takes '2' arguments
>


 
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
How can I click on a telephone number in an Excel 2002 spreadsheet, and have the number dialed? jbclem Microsoft Excel Misc 2 13th Aug 2009 01:57 AM
MessageFilter's Simon Microsoft Dot NET Compact Framework 4 19th Sep 2008 02:37 PM
E_INVALIDARG when using NOT in CDO MessageFilter Chris Fannin Microsoft Outlook VBA Programming 1 2nd Jun 2005 04:02 PM
form field,can I add a telephone number under the number field w/d =?Utf-8?B?cmVkd29sZmU1?= Microsoft Word Document Management 1 30th Nov 2004 10:48 PM
"hi-jacking" of a telephone line and fraudulent telephone calls levenern@aol.com Windows XP Security 8 18th Apr 2004 06:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:01 PM.