Searching for UserProperty

  • Thread starter Thread starter wizeguy
  • Start date Start date
W

wizeguy

I'm storing a unique number with a journal item. I want to be able to
search by that number and modify that entry later on. So far I can get
it stored fine by doing this.

Store info
=============
<snip>
Dim MyEntryID As Outlook.UserProperty
Set MyEntryID = MyOlItem.UserProperties.Add("EntryID", olText)
MyEntryID.Value = MyTime
<snip>

I can see the values stored in outlook but I'm unable to find the entry
thru code?

Look for entry
===============
<snip>
Dim objNameSpace As Outlook.NameSpace
Dim objJournals As Outlook.MAPIFolder
Dim objJournal As Outlook.UserPropert
Set objNameSpace = MyOlApp.GetNamespace("MAPI")
Set objJournals = objNameSpace.GetDefaultFolder(olFolderJournal)
This line needs help > Set objJournal = objJournals.UserProperties.Find("EntryID").Value = MyTime
<snip>

Thanks. :)
 
Three problems:

1) Outlook items already have a property named EntryID. You can't create a custom property with the same name. Pick another name. I used NewEntryIDProperty in the example below.

2) You're using Find on the wrong object. When you want to locate an item in a folder, you need to use the Find method on the folder's Items collection.

3) If the value you're searching for is a string literal, it must be enclosed in quotation marks:

strFind = "[NewEntryIDProperty] = " & Chr(34) & somevalue & Chr(34)
Set itm = objJournals.Items.Find(strFind)
If Not itm Is Nothing Then
' do stuff with itm
End If

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top