A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Searching by User Property



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 23rd 07, 01:17 PM posted to microsoft.public.outlook.program_vba
Sick Boy
external usenet poster
 
Posts: 1
Default Searching by User Property

Hello.

My toolbar marks Outlook objects (Contacts and Appointments) by
setting my custom property
UserProperties("id") as number. I need to find Contacts by this id
property's value.

I've got 2 examples of my code:

1)
strFilter = "[MessageClass] 'IPM.Contacs' And [MessageClass]
'IPM.Contacu' And [id] '0'"
If FindFolder.Items.Count 0 Then
Set colObj = FindFolder.Items.Restrict(strFilter)
For i = 1 To colObj.Count
...
Next i
End If


2)
Set colContTest = FindFolder.Items.Restrict("[FirstName] = 'Fulvio'
And [LastName] = 'Grignani'")
If colContTest.Count 0 Then
Set oContTest = colContTest.GetFirst
id_t = oContTest.UserProperties("id")
cid_t = oContTest.UserProperties("cid")
End If
Set colContTest = FindFolder.Items.Restrict("[id] = '" & id_t &
"'")

The first part of code is used to delete all objects which have IDs.
It works OK.

The second part of code is taken from the procedure which is used to
find contact by id. It doesn't work correctly. It finds contact by
name and after that gets it's id and cid correctly. But it can't find
the same contatct by it's "id" property. The colContTest collection
have 1 object after executing the first string, but is empty after the
last string.
I don't understand why almost the same functionality works in one
procedure, but doesn't work in nother one.

Ads
  #2  
Old May 23rd 07, 06:47 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Searching by User Property

If those custom fields don't also exist in the folder then the Restrict
method should generate an error. Can you see them listed in the User Defined
Fields in Folder section of the Field Chooser?

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Sick Boy" wrote:

Hello.

My toolbar marks Outlook objects (Contacts and Appointments) by
setting my custom property
UserProperties("id") as number. I need to find Contacts by this id
property's value.

I've got 2 examples of my code:

1)
strFilter = "[MessageClass] 'IPM.Contacs' And [MessageClass]
'IPM.Contacu' And [id] '0'"
If FindFolder.Items.Count 0 Then
Set colObj = FindFolder.Items.Restrict(strFilter)
For i = 1 To colObj.Count
...
Next i
End If


2)
Set colContTest = FindFolder.Items.Restrict("[FirstName] = 'Fulvio'
And [LastName] = 'Grignani'")
If colContTest.Count 0 Then
Set oContTest = colContTest.GetFirst
id_t = oContTest.UserProperties("id")
cid_t = oContTest.UserProperties("cid")
End If
Set colContTest = FindFolder.Items.Restrict("[id] = '" & id_t &
"'")

The first part of code is used to delete all objects which have IDs.
It works OK.

The second part of code is taken from the procedure which is used to
find contact by id. It doesn't work correctly. It finds contact by
name and after that gets it's id and cid correctly. But it can't find
the same contatct by it's "id" property. The colContTest collection
have 1 object after executing the first string, but is empty after the
last string.
I don't understand why almost the same functionality works in one
procedure, but doesn't work in nother one.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
delete property Nikolas Outlook - Using Forms 13 February 28th 07 07:53 PM
Sent or Recieved Email Property Irene Outlook and VBA 1 February 2nd 07 08:31 PM
MailItem To property and display name Olivier Langlois Outlook and VBA 1 September 11th 06 05:10 PM
MessageClass Property of a Post Geoff Outlook and VBA 13 June 27th 06 08:49 AM
Set MailItem.Sender Property Joshua Ellul Add-ins for Outlook 2 June 8th 06 06:30 PM


All times are GMT +1. The time now is 03:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.