how to add custom properties to folder?
Author |
Message |
Rinzwi #1 / 10
|
 how to add custom properties to folder?
I want to distribute my custom form. However, Outlook will not add folder properties... (I am using a COM Addin for searching the items) I have tried to add the userproperties with CDO by code. However the folder properties were not correctly "linked" to the item properties. This is the question: How can I distribute a form template (.oft) correctly with item properties and folder properties? Can someone give me some example code? I've tried the following to "copy" the item fields to the folder: Private Sub AddCDOFolderProp(objItem As Object) 'Doel: 'Gaat alle userproperties in een item af en zet deze in zijn bijbehorende map '(te vinden onder tab Item->Alle velden->[Map naam]). Daarbij wordt gebruik gemaakt 'van CDO objecten. On Error GoTo AddCDOFolderProp_Err Dim objFolder As outlook.MAPIFolder Dim objCDOFolder As Folder Dim objProp As outlook.UserProperty Dim strFolderID As String Dim strStoreID As String Dim intCDOType As Integer Set objFolder = objItem.Parent Set objCDOFolder = objSession.GetFolder(strFolderID, strStoreID) strFolderID = objFolder.EntryID strStoreID = objFolder.StoreID For Each objProp In objItem.UserProperties 'Omzetten Outlook item type naar VB type Select Case objProp.Type Case olNumber intCDOType = vbInteger Case olText intCDOType = vbString Case olPercent intCDOType = vbInteger Case olDateTime intCDOType = vbDate Case olCurrency intCDOType = vbCurrency Case olDuration intCDOType = vbInteger Case olYesNo intCDOType = vbBoolean Case Else intCDOType = vbVariant End Select objCDOFolder.Fields.Add objProp.Name, intCDOType Next Exit Sub AddCDOFolderProp_Err: ErrorHandler "Toevoegen map velden mislukt (CDO)" End Sub
|
Sun, 04 Jul 2004 22:32:45 GMT |
|
 |
Sue Mosher [MVP #2 / 10
|
 how to add custom properties to folder?
Try using Outlook to add the properties. Create an item in the folder, and add the property to its UserProperties collection with the correct parameters for that property. Then discard the item. -- Sue Mosher, Outlook MVP Outlook and Exchange Solutions at http://www.slipstick.com Quote:
> I want to distribute my custom form. However, Outlook will not add > folder properties... (I am using a COM Addin for searching the items) > I have tried to add the userproperties with CDO by code. However the > folder properties were not correctly "linked" to the item properties.
|
Mon, 05 Jul 2004 06:36:40 GMT |
|
 |
Rinzwi #3 / 10
|
 how to add custom properties to folder?
btw Set objCDOFolder = objSession.GetFolder(strFolderID, strStoreID) needs to be under the line strStoreID = objFolder.StoreID however it won't do the trick I've changed the code to objCDOFolder.Fields.Add(objProp.Name, intCDOType, objProp.Value) and then objCDOFolder.Update, but then I get the error MAPI_E_NO_SUPPORT. When I drop the parameter objProp.Value I don't get an error, but the fields are not added either... I think microsoft should support better distribution methods of custom forms. But those guys won't change a thing.. Outlook 2002 is almost the same as 2000. [off topic] Another problem is that ActiveX components still won't work properly (unknown properties etc). I am now using a DHTML page which is viewed through the outlook form. Really stupid. I ought to think that implementing a technology from one program to another shouldn't be a realy big problem... I am going to try you're method, but if you (or someone else) are willing to try my code and see if you can find a solution I would appreciate it very much.
Quote: > Try using Outlook to add the properties. Create an item in the folder, > and add the property to its UserProperties collection with the correct > parameters for that property. Then discard the item. > -- > Sue Mosher, Outlook MVP > Outlook and Exchange Solutions > at http://www.slipstick.com
> > I want to distribute my custom form. However, Outlook will not add > > folder properties... (I am using a COM Addin for searching the items) > > I have tried to add the userproperties with CDO by code. However the > > folder properties were not correctly "linked" to the item properties.
|
Mon, 05 Jul 2004 18:30:38 GMT |
|
 |
Rinzwi #4 / 10
|
 how to add custom properties to folder?
I've tried you're method: Private Sub AddCDOFolderProp(objItem As Object) On Error GoTo AddCDOFolderProp_Err Dim objFolder As Outlook.MAPIFolder Dim objProp As Outlook.UserProperty Dim objNewItem As Object Set objFolder = objItem.Parent Set objNewItem = objFolder.Items.Add For Each objProp In objItem.UserProperties objNewItem.UserProperties.Add objProp.Name, objProp.Type, True Next objNewItem.Delete Exit Sub AddCDOFolderProp_Err: ErrorHandler "Toevoegen map velden mislukt! (CDO)" End Sub However, the folder fields won't link with the item fields. With this I mean that strSearch = "[idWerknemersID] = " & ID Set objContact = objItems.Find(strSearch) always returns nothing. Can you help me out?
Quote: > Try using Outlook to add the properties. Create an item in the folder, > and add the property to its UserProperties collection with the correct > parameters for that property. Then discard the item. > -- > Sue Mosher, Outlook MVP > Outlook and Exchange Solutions > at http://www.slipstick.com
> > I want to distribute my custom form. However, Outlook will not add > > folder properties... (I am using a COM Addin for searching the items) > > I have tried to add the userproperties with CDO by code. However the > > folder properties were not correctly "linked" to the item properties.
|
Mon, 05 Jul 2004 19:15:43 GMT |
|
 |
Sue Mosher [MVP #5 / 10
|
 how to add custom properties to folder?
What kind if field is idWerknemersID? If it's Text, you need quotation marks around ID. Quote:
> I've tried you're method: > Private Sub AddCDOFolderProp(objItem As Object) > On Error GoTo AddCDOFolderProp_Err > Dim objFolder As Outlook.MAPIFolder > Dim objProp As Outlook.UserProperty > Dim objNewItem As Object > Set objFolder = objItem.Parent > Set objNewItem = objFolder.Items.Add > For Each objProp In objItem.UserProperties > objNewItem.UserProperties.Add objProp.Name, objProp.Type, True > Next > objNewItem.Delete > Exit Sub > AddCDOFolderProp_Err: > ErrorHandler "Toevoegen map velden mislukt! (CDO)" > End Sub > However, the folder fields won't link with the item fields. With this > I mean that > strSearch = "[idWerknemersID] = " & ID > Set objContact = objItems.Find(strSearch) always returns nothing. > Can you help me out?
> > Try using Outlook to add the properties. Create an item in the folder, > > and add the property to its UserProperties collection with the correct > > parameters for that property. Then discard the item. > > -- > > Sue Mosher, Outlook MVP > > Outlook and Exchange Solutions > > at http://www.slipstick.com
> > > I want to distribute my custom form. However, Outlook will not add > > > folder properties... (I am using a COM Addin for searching the items) > > > I have tried to add the userproperties with CDO by code. However the > > > folder properties were not correctly "linked" to the item properties.
|
Mon, 05 Jul 2004 22:22:40 GMT |
|
 |
Rinzwi #6 / 10
|
 how to add custom properties to folder?
it's an integer. outlook just seems to not link the item properties to the folder properties. When I change a userproperty in the item (by opening a standard contact item and the the tab "all fields"), the custom folder properties remains empty. When I give it a value in the folder properties the item field will get the value, but the folder field won't keep the value (it stays empty)
Quote: > What kind if field is idWerknemersID? If it's Text, you need quotation > marks around ID.
> > I've tried you're method: > > Private Sub AddCDOFolderProp(objItem As Object) > > On Error GoTo AddCDOFolderProp Err > > Dim objFolder As Outlook.MAPIFolder > > Dim objProp As Outlook.UserProperty > > Dim objNewItem As Object > > Set objFolder = objItem.Parent > > Set objNewItem = objFolder.Items.Add > > For Each objProp In objItem.UserProperties > > objNewItem.UserProperties.Add objProp.Name, objProp.Type, True > > Next > > objNewItem.Delete > > Exit Sub > > AddCDOFolderProp Err: > > ErrorHandler "Toevoegen map velden mislukt! (CDO)" > > End Sub > > However, the folder fields won't link with the item fields. With this > > I mean that > > strSearch = "[idWerknemersID] = " & ID > > Set objContact = objItems.Find(strSearch) always returns nothing. > > Can you help me out?
> > > Try using Outlook to add the properties. Create an item in the > folder, > > > and add the property to its UserProperties collection with the > correct > > > parameters for that property. Then discard the item. > > > -- > > > Sue Mosher, Outlook MVP > > > Outlook and Exchange Solutions > > > at http://www.slipstick.com
> > > > I want to distribute my custom form. However, Outlook will not add > > > > folder properties... (I am using a COM Addin for searching the > items) > > > > I have tried to add the userproperties with CDO by code. However > the > > > > folder properties were not correctly "linked" to the item > properties.
|
Tue, 06 Jul 2004 06:24:07 GMT |
|
 |
Sue Mosher [MVP #7 / 10
|
 how to add custom properties to folder?
It just plain sounds like something's wrong with the way that field was created, maybe going back to what you did with CDO. On the All Fields tab, do you see the same field name in both All Fields in Folder and All Fields in Item? Select the field in each place and click Properties. Do they match? Watch out for typos. You might want to: 1) Make a backup of your form as an .oft file. 2) Delete the field from All Fields in Folder 3) Open the form design, delete the field from the form. 4) Create the field anew using the Field Chooser. 5) Drag the field onto any custom Outlook form page to add it to the form. You can hide that page after you add it. 6) Republish the form under the same name. Another cleanup method might be to do all the above, but use a new name for the property. Then write code to copy the data from the existing items from the old field into the new one. -- Quote:
> it's an integer. outlook just seems to not link the item properties to > the folder properties. When I change a userproperty in the item (by > opening a standard contact item and the the tab "all fields"), the > custom folder properties remains empty. When I give it a value in the > folder properties the item field will get the value, but the folder > field won't keep the value (it stays empty)
> > What kind if field is idWerknemersID? If it's Text, you need quotation > > marks around ID.
> > > I've tried you're method: > > > Private Sub AddCDOFolderProp(objItem As Object) > > > On Error GoTo AddCDOFolderProp Err > > > Dim objFolder As Outlook.MAPIFolder > > > Dim objProp As Outlook.UserProperty > > > Dim objNewItem As Object > > > Set objFolder = objItem.Parent > > > Set objNewItem = objFolder.Items.Add > > > For Each objProp In objItem.UserProperties > > > objNewItem.UserProperties.Add objProp.Name, objProp.Type, True > > > Next > > > objNewItem.Delete > > > Exit Sub > > > AddCDOFolderProp Err: > > > ErrorHandler "Toevoegen map velden mislukt! (CDO)" > > > End Sub > > > However, the folder fields won't link with the item fields. With this > > > I mean that > > > strSearch = "[idWerknemersID] = " & ID > > > Set objContact = objItems.Find(strSearch) always returns nothing. > > > Can you help me out?
> > > > Try using Outlook to add the properties. Create an item in the > > folder, > > > > and add the property to its UserProperties collection with the > > correct > > > > parameters for that property. Then discard the item. > > > > -- > > > > Sue Mosher, Outlook MVP > > > > Outlook and Exchange Solutions > > > > at http://www.slipstick.com
> > > > > I want to distribute my custom form. However, Outlook will not add > > > > > folder properties... (I am using a COM Addin for searching the > > items) > > > > > I have tried to add the userproperties with CDO by code. However > > the > > > > > folder properties were not correctly "linked" to the item > > properties.
|
Tue, 06 Jul 2004 06:43:47 GMT |
|
 |
Rinzwi #8 / 10
|
 how to add custom properties to folder?
I'm using this method: Private Sub AddCDOFolderProp(objItem As Object, objFolder As outlook.MAPIFolder) On Error GoTo AddCDOFolderProp_Err 'Dim objFolder As outlook.MAPIFolder Dim objProp As outlook.UserProperty Dim objNewItem As TaskItem 'Set objFolder = objItem.Parent Set objNewItem = objFolder.Items.Add For Each objProp In objItem.UserProperties objNewItem.UserProperties.Add objProp.Name, objProp.Type, True, 1 Next 'objNewItem.Save objNewItem.Delete Exit Sub AddCDOFolderProp_Err: ErrorHandler "Toevoegen map velden mislukt! (CDO)" End Sub I found out that it works for fields of type string, date, ed. But the strange thing is that integer types won't work correctly and have the problem I described...
Quote: > It just plain sounds like something's wrong with the way that field was > created, maybe going back to what you did with CDO. On the All Fields > tab, do you see the same field name in both All Fields in Folder and All > Fields in Item? Select the field in each place and click Properties. Do > they match? Watch out for typos. > You might want to: > 1) Make a backup of your form as an .oft file. > 2) Delete the field from All Fields in Folder > 3) Open the form design, delete the field from the form. > 4) Create the field anew using the Field Chooser. > 5) Drag the field onto any custom Outlook form page to add it to the > form. You can hide that page after you add it. > 6) Republish the form under the same name. > Another cleanup method might be to do all the above, but use a new name > for the property. Then write code to copy the data from the existing > items from the old field into the new one. > --
> > it's an integer. outlook just seems to not link the item properties to > > the folder properties. When I change a userproperty in the item (by > > opening a standard contact item and the the tab "all fields"), the > > custom folder properties remains empty. When I give it a value in the > > folder properties the item field will get the value, but the folder > > field won't keep the value (it stays empty)
> > > What kind if field is idWerknemersID? If it's Text, you need > quotation > > > marks around ID.
> > > > I've tried you're method: > > > > Private Sub AddCDOFolderProp(objItem As Object) > > > > On Error GoTo AddCDOFolderProp Err > > > > Dim objFolder As Outlook.MAPIFolder > > > > Dim objProp As Outlook.UserProperty > > > > Dim objNewItem As Object > > > > Set objFolder = objItem.Parent > > > > Set objNewItem = objFolder.Items.Add > > > > For Each objProp In objItem.UserProperties > > > > objNewItem.UserProperties.Add objProp.Name, objProp.Type, > True > > > > Next > > > > objNewItem.Delete > > > > Exit Sub > > > > AddCDOFolderProp Err: > > > > ErrorHandler "Toevoegen map velden mislukt! (CDO)" > > > > End Sub > > > > However, the folder fields won't link with the item fields. With > this > > > > I mean that > > > > strSearch = "[idWerknemersID] = " & ID > > > > Set objContact = objItems.Find(strSearch) always returns > nothing. > > > > Can you help me out?
> > > > > Try using Outlook to add the properties. Create an item in the > folder, > > > > > and add the property to its UserProperties collection with the > correct > > > > > parameters for that property. Then discard the item. > > > > > -- > > > > > Sue Mosher, Outlook MVP > > > > > Outlook and Exchange Solutions > > > > > at http://www.slipstick.com
> > > > > > I want to distribute my custom form. However, Outlook will not > add > > > > > > folder properties... (I am using a COM Addin for searching the > items) > > > > > > I have tried to add the userproperties with CDO by code. > However > the > > > > > > folder properties were not correctly "linked" to the item > > > properties.
|
Tue, 06 Jul 2004 18:13:28 GMT |
|
 |
Rinzwi #9 / 10
|
 how to add custom properties to folder?
I've found a post where the same problem is described. No answer though... http://groups.google.com/groups?q=integer+type+outlook+form&hl=nl&sel...
Quote: > It just plain sounds like something's wrong with the way that field was > created, maybe going back to what you did with CDO. On the All Fields > tab, do you see the same field name in both All Fields in Folder and All > Fields in Item? Select the field in each place and click Properties. Do > they match? Watch out for typos. > You might want to: > 1) Make a backup of your form as an .oft file. > 2) Delete the field from All Fields in Folder > 3) Open the form design, delete the field from the form. > 4) Create the field anew using the Field Chooser. > 5) Drag the field onto any custom Outlook form page to add it to the > form. You can hide that page after you add it. > 6) Republish the form under the same name. > Another cleanup method might be to do all the above, but use a new name > for the property. Then write code to copy the data from the existing > items from the old field into the new one. > --
> > it's an integer. outlook just seems to not link the item properties to > > the folder properties. When I change a userproperty in the item (by > > opening a standard contact item and the the tab "all fields"), the > > custom folder properties remains empty. When I give it a value in the > > folder properties the item field will get the value, but the folder > > field won't keep the value (it stays empty)
> > > What kind if field is idWerknemersID? If it's Text, you need > quotation > > > marks around ID.
> > > > I've tried you're method: > > > > Private Sub AddCDOFolderProp(objItem As Object) > > > > On Error GoTo AddCDOFolderProp Err > > > > Dim objFolder As Outlook.MAPIFolder > > > > Dim objProp As Outlook.UserProperty > > > > Dim objNewItem As Object > > > > Set objFolder = objItem.Parent > > > > Set objNewItem = objFolder.Items.Add > > > > For Each objProp In objItem.UserProperties > > > > objNewItem.UserProperties.Add objProp.Name, objProp.Type, > True > > > > Next > > > > objNewItem.Delete > > > > Exit Sub > > > > AddCDOFolderProp Err: > > > > ErrorHandler "Toevoegen map velden mislukt! (CDO)" > > > > End Sub > > > > However, the folder fields won't link with the item fields. With > this > > > > I mean that > > > > strSearch = "[idWerknemersID] = " & ID > > > > Set objContact = objItems.Find(strSearch) always returns > nothing. > > > > Can you help me out?
> > > > > Try using Outlook to add the properties. Create an item in the > folder, > > > > > and add the property to its UserProperties collection with the > correct > > > > > parameters for that property. Then discard the item. > > > > > -- > > > > > Sue Mosher, Outlook MVP > > > > > Outlook and Exchange Solutions > > > > > at http://www.slipstick.com
> > > > > > I want to distribute my custom form. However, Outlook will not > add > > > > > > folder properties... (I am using a COM Addin for searching the > items) > > > > > > I have tried to add the userproperties with CDO by code. > However > the > > > > > > folder properties were not correctly "linked" to the item > > > properties.
|
Tue, 06 Jul 2004 18:17:11 GMT |
|
 |
Sue Mosher [MVP #10 / 10
|
 how to add custom properties to folder?
Which specific Outlook UserProperty.Type value is causing a problem? That will give me something to test. Quote:
> I'm using this method: > Private Sub AddCDOFolderProp(objItem As Object, objFolder As > outlook.MAPIFolder) > On Error GoTo AddCDOFolderProp_Err > 'Dim objFolder As outlook.MAPIFolder > Dim objProp As outlook.UserProperty > Dim objNewItem As TaskItem > 'Set objFolder = objItem.Parent > Set objNewItem = objFolder.Items.Add > For Each objProp In objItem.UserProperties > objNewItem.UserProperties.Add objProp.Name, objProp.Type, > True, 1 > Next > 'objNewItem.Save > objNewItem.Delete > Exit Sub > AddCDOFolderProp_Err: > ErrorHandler "Toevoegen map velden mislukt! (CDO)" > End Sub > I found out that it works for fields of type string, date, ed. But the > strange thing is that integer types won't work correctly and have the > problem I described...
> > It just plain sounds like something's wrong with the way that field was > > created, maybe going back to what you did with CDO. On the All Fields > > tab, do you see the same field name in both All Fields in Folder and All > > Fields in Item? Select the field in each place and click Properties. Do > > they match? Watch out for typos. > > You might want to: > > 1) Make a backup of your form as an .oft file. > > 2) Delete the field from All Fields in Folder > > 3) Open the form design, delete the field from the form. > > 4) Create the field anew using the Field Chooser. > > 5) Drag the field onto any custom Outlook form page to add it to the > > form. You can hide that page after you add it. > > 6) Republish the form under the same name. > > Another cleanup method might be to do all the above, but use a new name > > for the property. Then write code to copy the data from the existing > > items from the old field into the new one. > > --
> > > it's an integer. outlook just seems to not link the item properties to > > > the folder properties. When I change a userproperty in the item (by > > > opening a standard contact item and the the tab "all fields"), the > > > custom folder properties remains empty. When I give it a value in the > > > folder properties the item field will get the value, but the folder > > > field won't keep the value (it stays empty)
> > > > What kind if field is idWerknemersID? If it's Text, you need > > quotation > > > > marks around ID.
> > > > > I've tried you're method: > > > > > Private Sub AddCDOFolderProp(objItem As Object) > > > > > On Error GoTo AddCDOFolderProp Err > > > > > Dim objFolder As Outlook.MAPIFolder > > > > > Dim objProp As Outlook.UserProperty > > > > > Dim objNewItem As Object > > > > > Set objFolder = objItem.Parent > > > > > Set objNewItem = objFolder.Items.Add > > > > > For Each objProp In objItem.UserProperties > > > > > objNewItem.UserProperties.Add objProp.Name, objProp.Type, > > True > > > > > Next > > > > > objNewItem.Delete > > > > > Exit Sub > > > > > AddCDOFolderProp Err: > > > > > ErrorHandler "Toevoegen map velden mislukt! (CDO)" > > > > > End Sub > > > > > However, the folder fields won't link with the item fields. With > > this > > > > > I mean that > > > > > strSearch = "[idWerknemersID] = " & ID > > > > > Set objContact = objItems.Find(strSearch) always returns > > nothing.
> > > > > > > I want to distribute my custom form. However, Outlook will not > > add > > > > > > > folder properties... (I am using a COM Addin for searching the > > items) > > > > > > > I have tried to add the userproperties with CDO by code. > > However > > the > > > > > > > folder properties were not correctly "linked" to the item > > > > properties.
|
Sun, 11 Jul 2004 21:09:05 GMT |
|
|
|