Y
Yuva
Hi,
I got the following error when I am trying to add the user properties to the
post item while developing Outlook 2007 Addin.
My outlook addin connects to TFS, and adds the workitems from the selected
server and project to the local Outlook PST file. The workitems are being
added to the corresponding PST folder as a post item. My code works fine when
I give the columns to be added by default as below:
{
PostItem postItem = folder.Items.Add(OlItemType.olPostItem) as PostItem;
postItem.Subject = workItem.Title;
UserProperty property = postItem.UserProperties.Add("WorkItemType",
OlUserPropertyType.olText,Type.Missing, Type.Missing);
property.Value = workItem.Type.Name;
property = postItem.UserProperties.Add("ID", OlUserPropertyType.olText,
Type.Missing,Type.Missing);
property.Value = workItem.Id;
property = postItem.UserProperties.Add("WorkItemTitle",
OlUserPropertyType.olText, Type.Missing,Type.Missing);
property.Value = workItem.Title;
postItem.Save();
}
but it gives me the error when I try to add the properties dynamically using
foreach loop as below:
foreach (WorkItem workItem in workItems)
{
PostItem postItem = folder.Items.Add(OlItemType.olPostItem) as PostItem;
UserProperty property = null;
foreach (FieldDefinition fieldDefinition in workItems.DisplayFields)
{
property = postItem.UserProperties.Add(fieldDefinition.Name,
OlUserPropertyType.olText,
Type.Missing,
Type.Missing);
property.Value = workItem.Fields[fieldDefinition.ReferenceName].Value;
}
postItem.Save();
}
The error is:
{System.Runtime.InteropServices.COMException (0x8004E002):
A field with this name already exists in the "All Document fields" field
set. Enter a different name.
at Microsoft.Office.Interop.Outlook.UserProperties.Add(String Name,
OlUserPropertyType Type, Object AddToFolderFields, Object DisplayFormat)
at WorkItemFolderView.CreatePostWorkItem(MAPIFolder folder,
WorkItemCollection workItems)
Can anyone help me out with this error. Am not well versed with coding, so
am sorry if there is some basic error. Looking for your help!!!
Thanks in Advance,
Yuva
I got the following error when I am trying to add the user properties to the
post item while developing Outlook 2007 Addin.
My outlook addin connects to TFS, and adds the workitems from the selected
server and project to the local Outlook PST file. The workitems are being
added to the corresponding PST folder as a post item. My code works fine when
I give the columns to be added by default as below:
{
PostItem postItem = folder.Items.Add(OlItemType.olPostItem) as PostItem;
postItem.Subject = workItem.Title;
UserProperty property = postItem.UserProperties.Add("WorkItemType",
OlUserPropertyType.olText,Type.Missing, Type.Missing);
property.Value = workItem.Type.Name;
property = postItem.UserProperties.Add("ID", OlUserPropertyType.olText,
Type.Missing,Type.Missing);
property.Value = workItem.Id;
property = postItem.UserProperties.Add("WorkItemTitle",
OlUserPropertyType.olText, Type.Missing,Type.Missing);
property.Value = workItem.Title;
postItem.Save();
}
but it gives me the error when I try to add the properties dynamically using
foreach loop as below:
foreach (WorkItem workItem in workItems)
{
PostItem postItem = folder.Items.Add(OlItemType.olPostItem) as PostItem;
UserProperty property = null;
foreach (FieldDefinition fieldDefinition in workItems.DisplayFields)
{
property = postItem.UserProperties.Add(fieldDefinition.Name,
OlUserPropertyType.olText,
Type.Missing,
Type.Missing);
property.Value = workItem.Fields[fieldDefinition.ReferenceName].Value;
}
postItem.Save();
}
The error is:
{System.Runtime.InteropServices.COMException (0x8004E002):
A field with this name already exists in the "All Document fields" field
set. Enter a different name.
at Microsoft.Office.Interop.Outlook.UserProperties.Add(String Name,
OlUserPropertyType Type, Object AddToFolderFields, Object DisplayFormat)
at WorkItemFolderView.CreatePostWorkItem(MAPIFolder folder,
WorkItemCollection workItems)
Can anyone help me out with this error. Am not well versed with coding, so
am sorry if there is some basic error. Looking for your help!!!
Thanks in Advance,
Yuva