Folder userproperties

Add-in Express™ Support Service
That's what is more important than anything else

Folder userproperties
 
Rick Koch




Posts: 172
Joined: 2006-09-05
Does ADX give any ability to access custom properties on folders (as in "User-defined fields in folder?"

I realize I can add new properties to either the message or the message & the folder. It would be helpful to me to be able to add or detect user properties at the folder level.

Rick
Posted 07 Sep, 2006 16:06:03 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Rick.

The fact is that Outlook folders don't have custom properties. You can add them to Outlook items only using the Outlook Object Model.
e.g.

UserProperty myProp = myItem.UserProperties.Add("MyPropName", Outlook.OlUserPropertyType.olText, false, Type.Missing);



Posted 07 Sep, 2006 18:03:07 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
As to the "User-defined fields", you can't access them directly because they are defined in the XML property of the View objects.
You can access all views for a particular folder via the Views property of the Outlook folder.
Posted 07 Sep, 2006 18:09:52 Top
Rick Koch




Posts: 172
Joined: 2006-09-05
Thanks. We're building an application that will have to convert some existing data.

The existing data is associated with an existing custom property, and the new/converted data has its own custom properties as well.

I was thinking about checking the folder for the old property to determine whether conversion is necessary. If the conversion code has to iterate over the entire folder to see if any unconverted records exist, each time the user starts Outlook, then that seems like a lot of wasted time.

What is the best way to alter the machine such that my code will be able to tell, with the least possible processor overhead, that the folder contents have already been converted, without wasting clock cycles looking for unconverted legacy data on a store that's already been processed?
Posted 08 Sep, 2006 16:46:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Rick, try to use named properties for the Outlook folder to determine whether conversion is necessary.
Please download the following example to learn how it can be done via Extended MAPI:
http://www.add-in-express.com/projects/newemailsexample.zip
Now the example adds named properties to Outlook mail items. You can use the same technique to add them to Outlook folders.

Posted 08 Sep, 2006 22:52:33 Top
kathy li




Posts: 1
Joined: 2006-12-20

Const OL_SCHEMA_VIEW_USERPROP As String = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}"

objName = New Application().GetNamespace(Type:="MAPI")
olItems = objName.GetDefaultFolder(FolderType:=OlDefaultFolders.olFolderDrafts).Items

objViewInboxs = objName.GetDefaultFolder(FolderType:=OlDefaultFolders.olFolderDrafts).Views

For Each objViewInbox In objViewInboxs
If objViewInbox.Name = strName Then
objView = objViewInbox
foundView = True
Exit For
End If
Next


If (foundView = False) Then
objView = objViewInboxs.Add(strName, OlViewType.olTableView, OlViewSaveOption.olViewSaveOptionAllFoldersOfType)
End If

If Not (objView Is Nothing) Then
'find this user declared variable
'declare a variable


oMI = objView.Application.CreateItem(OlItemType.olMailItem)
oMI.UserProperties.Add(strHead, OlUserPropertyType.olYesNo, True)
oMI.Close(OlInspectorClose.olDiscard)
loadTrue = objXMLDoc.loadXML(bstrXML:=objView.XML)
'Create a reference to the root element.
objRoot = objXMLDoc.documentElement
'Walk the tree to obtain a column node.

With objRoot.insertBefore(newChild:=objXMLDoc.createElement("column"), refChild:=objRoot.selectNodes("column").item(8))
'Add properties to the new column.
.appendChild(newChild:=objXMLDoc.createElement(tagName:="heading")).text = strName
.appendChild(newChild:=objXMLDoc.createElement(tagName:="prop")).text = strProp
.appendChild(newChild:=objXMLDoc.createElement(tagName:="width")).text = 50
.appendChild(newChild:=objXMLDoc.createElement(tagName:="type")).text = "ie4"

'Copy the schema from the parser to the View object.
objView.XML = objXMLDoc.xml
'Save the schema.4
'Apply the changes to the view.

objView.Save()
objView.Apply()

I was using this code to add a user defined filed and post it on the header. Some problems related to it:
I called the XML com object

1. Through a COM run time error most of time
2. I created a user defined field and add it into head successfully, then I deleted it from header, I change a type of this field through code, then when I run this program, it always say that the fields exisit, enter another name. I delete it through customer view on outlook, but when I run this program, it cannot find this field, but when I add it into userproperty, it always through a error to say it exists. How can I delete it and how can I find it exist. the Code oMI.UserProperties.find(strHead) does return nothing, also oMI.UserProperties(strHead) return nothing. How can I delete oMI.Close(OlInspectorClose.olDiscard) it doesn't work either.

Give me a help, please.
Thanks
Kathy :D



Posted 20 Dec, 2006 16:59:43 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Kathy.

Where exactly in the code do you get errors?
Posted 21 Dec, 2006 09:48:03 Top