Cdo AddressEntryFilter does not work

M

Mita Garg

Hi All,

I am developing a small vb application. I am reading the address
entries from the address list (address list can be any of the address
List) and trying to filter out the names which has Business Fax
number. But it just does'nt work. Can any one tell me, where I am
going wrong.

Your help will be really appreciated.

Private Sub Command1_Click()
Dim objCdo As MAPI.Session
Dim objFolder As MAPI.Folder
Dim objAddressList As MAPI.AddressList
Dim objAddressLists As MAPI.AddressLists
Dim objFilter As AddressEntryFilter
Dim objAddressEntries As MAPI.AddressEntries
Dim objAddressEntry As MAPI.AddressEntry
Dim ctr As Integer
Dim s As String

Set objCdo = CreateObject("MAPI.Session")
objCdo.Logon
Set objFolder = objCdo.Inbox
Set objAddressList = objCdo.AddressLists.Item("Contacts")
Set objAddressEntries = objAddressList.AddressEntries
ctr = objAddressEntries.Count ( I get ctr = 36)
Set objFilter = objAddressEntries.Filter
objFilter.Fields.Add CdoPR_BUSINESS_FAX_NUMBER, "BusinessFaxNumber"

' HERE I GET MAPI_E_TOO_COMPLEX
ctr = objAddressEntries.Count
End Sub


'I can get hold of the CdoPR_BUSINESS_FAX_NUMBER if i don't do any
filtering. So this indicates that i have got the Contacts which has
Business Fax Numbers.

Tks Mita
 
K

Ken Slovak - [MVP - Outlook]

M

Mita Garg

Thanks Ken for your time. But then what should the filtering look
like. Definitely i want to filter it on BUSINESS_FAX_NUMBER, if not
this one
(objFilter.Fields.Add CdoPR_BUSINESS_FAX_NUMBER, "BusinessFaxNumber").

Regards
Mita

Ken Slovak - said:
You are trying to filter on the business fax number being equal to
"BusinessFaxNumber". I don't think that would ever be the case.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Mita Garg said:
Hi All,

I am developing a small vb application. I am reading the address
entries from the address list (address list can be any of the address
List) and trying to filter out the names which has Business Fax
number. But it just does'nt work. Can any one tell me, where I am
going wrong.

Your help will be really appreciated.

Private Sub Command1_Click()
Dim objCdo As MAPI.Session
Dim objFolder As MAPI.Folder
Dim objAddressList As MAPI.AddressList
Dim objAddressLists As MAPI.AddressLists
Dim objFilter As AddressEntryFilter
Dim objAddressEntries As MAPI.AddressEntries
Dim objAddressEntry As MAPI.AddressEntry
Dim ctr As Integer
Dim s As String

Set objCdo = CreateObject("MAPI.Session")
objCdo.Logon
Set objFolder = objCdo.Inbox
Set objAddressList = objCdo.AddressLists.Item("Contacts")
Set objAddressEntries = objAddressList.AddressEntries
ctr = objAddressEntries.Count ( I get ctr = 36)
Set objFilter = objAddressEntries.Filter
objFilter.Fields.Add CdoPR_BUSINESS_FAX_NUMBER, "BusinessFaxNumber"

' HERE I GET MAPI_E_TOO_COMPLEX
ctr = objAddressEntries.Count
End Sub


'I can get hold of the CdoPR_BUSINESS_FAX_NUMBER if i don't do any
filtering. So this indicates that i have got the Contacts which has
Business Fax Numbers.

Tks Mita
 
K

Ken Slovak - [MVP - Outlook]

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