Create and Get user-defined fields in folder

  • Thread starter Thread starter ck
  • Start date Start date
C

ck

Hi,

I have a COM add-in created using VB6. I need to create user-defined fields
in one of the contact folder and get the user-defined fields value for usage
later.

Does anyone know how to create user-defined fields on contact folder and
retrieve the created user-defined fields value?

Thanks!

ck
 
Do you want the properties on the folder object itself or on items in the
folder? Folder properties would have to be created using something like
Extended MAPI or Redemption or CDO 1.21. For user properties on items just
add the user property to an item and set the add to folder fields argument.
 
Hi Ken,
Thanks for the reply. i need to add and get the properties in the folder
object. Actually i do manage to add properties to folder object using this
piece of code:

Set objContact = objNewFolder.Items.Add(olContactItem)
Set OlUserProperty = objContact.UserProperties.Add("GroupID", olNumber)
objContact.Save

BUT by doing this, i will need to add the contact item to the folder. I just
want the properties to be in folder object.

So, how to achieve this using Redemption or CDO 1.21? Any website/sample
that i can go through?
 
Hi Ken,
Thanks for the reply. i need to add and get the properties in the folder
object. Actually i do manage to add properties to folder object using this
piece of code:

Set objContact = objNewFolder.Items.Add(olContactItem)
Set OlUserProperty = objContact.UserProperties.Add("GroupID", olNumber)
objContact.Save

BUT by doing this, i will need to add the contact item to the folder. I just
want the properties to be in folder object.

So, how to achieve this using Redemption or CDO 1.21? Any website/sample
that i can go through?
 
Hi Ken,
Thanks for the reply. i need to add and get the properties in the folder
object. Actually i do manage to add properties to folder object using this
piece of code:

Set objContact = objNewFolder.Items.Add(olContactItem)
Set OlUserProperty = objContact.UserProperties.Add("GroupID", olNumber)
objContact.Save

BUT by doing this, i will need to add the contact item to the folder. I just
want the properties to be in folder object.

So, how to achieve this using Redemption or CDO 1.21? Any website/sample
that i can go through?
 
You don't need to save the item. It is enough that you created it in the folder and added a property to it. Just call Set objContact = Nothing when you're done with it.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
objContact.UserProperties("GroupID").Value would return the value of the GroupID property on any item to which that property has been added.

However, just because a property is defined in a folder doesn't mean that it exists yet on individual items or, by extension, has any values on those items. The property must be added to each item before a value can be set for it. The property is added automatically if the user assigns the property a value manually through in-cell editing or the All Fields page. Programmatically, your code would need to add the property to the item, then set its value before saving the item.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
No wonder i can't get any value from the property in folder. If i need to
assign the property to item before i can assign any value to the property,
property in item and folder are essentially the same. Then what is the
different between property on folder level and property on item level?

Sorry for all the annoying questions, i am still new to programming in
Outlook.
 
I think in almost all cases the store wouldn't let you create named
properties on a folder object. A user defined field in the folder is
probably the best you can do.

What would probably be a better alternative would be to create a hidden item
in the folder to hold any value or values you want. You can't do that either
with the Outlook object model (before Outlook 2007 where you can create a
"StorageItem". But you can create hidden items in CDO using
Folder.HiddenMessages.Add() and in Redemption using
RDOFolder.HiddenItems.Add().

CDO information is at www.cdolive.com and Redemption information is at
www.dimastr.com/redemption.
 
Folder properties are nothing more than descriptors telling Outlook the
property name, type, its MAPI GUID, how the property must be displayed, etc.
On teh low level, the definitions are stored in a hidden item in the folder.
The actual *values* of the properties must be set on each particular item.
Once set, Outlook can display them property in the explorer once you
modified the folder view to include your custom property.
Redemption can manipulate folder properties (without creating any temporary
items in that folder like OOM) through the RDOFolder2.FolderFields
collection - see
http://www.dimastr.com/redemption/rdo/RDOFolder.htm#rdofolder2

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top