0
votes

I would like to create User Properties using EWS so that they appear in the field chooser in Outlook. I know it's possible using VBA, the object model exposes an Item.UserProperties collection. However, using EWS I can only access Item.ExtendedProperty.

The issue with ExtendedProperty is that is doesn't appear in the selectable user properties list.

The underlying issue is that our server-side application tries to work nicely together with the Dynamics CRM Outlook Client. The CRM Outlook client uses UserProperty for storing custom properties and our application can only work with EWS and we cannot find a way to create user properties.

Some example code:

User Properties (VBA Outlook):

Dim WithEvents m_objApp As Outlook.AppointmentItem

Private Sub Application_ItemLoad(ByVal Item As Object)

If Item.Class = olAppointment Then
    Set m_objApp = Item
End If

End Sub

Private Sub m_objApp_Open(Cancel As Boolean)

Dim oProp1 As UserProperty
Dim oProp2 As UserProperty

If m_objApp.UserProperties.Count = 0 Then
    Set oProp1 = m_objApp.UserProperties.Add("crmid", olText)
    oProp1.Value = ""
    Set oProp2 = m_objApp.UserProperties.Add("crmLinkState", olText)
    oProp2.Value = "0"
    m_objApp.Save
End If

End Sub

Extended Properties (Exchange EWS):

        CalendarItemType item = new CalendarItemType();
        item.MeetingTimeZone = new TimeZoneType() { TimeZoneName = _userTimeZone };
        item.StartSpecified = true;
        item.Start = GetDateFromXml(node.Value);
        item.EndSpecified = true;
        item.End = GetDateFromXml(node.Value);

        List<ExtendedPropertyType> properties = new List<ExtendedPropertyType>();
        properties.Add(CreateExtendedProperty("crmid", pending.CrmId.Value.ToString(), MapiPropertyTypeType.String));
        properties.Add(CreateExtendedProperty("crmLinkState", "2", MapiPropertyTypeType.Double));
        item.ExtendedProperty = properties.ToArray();

        CreateRequest createRequest = new CreateItemType()
            {
                Items = new NonEmptyArrayOfAllItemsType
                {
                    Items = new ItemType[] { item }
                },
                SavedItemFolderId = new TargetFolderIdType()
                {
                    Item = new DistinguishedFolderIdType()
                    {
                        Id = folder,
                        Mailbox = new EmailAddressType() { EmailAddress = _user.MailBox }
                    }
                },
                SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone,
                SendMeetingInvitationsSpecified = true
            };

       CreateItemResponseType response = exchange.CreateItem(createRequest);

    private ExtendedPropertyType CreateExtendedProperty(string name, string value, MapiPropertyTypeType type)
    {
        return new ExtendedPropertyType()
        {
            ExtendedFieldURI = new PathToExtendedFieldType()
            {
                PropertyName = name,
                DistinguishedPropertySetId = DistinguishedPropertySetType.PublicStrings,
                DistinguishedPropertySetIdSpecified = true,
                PropertyType = type
            },
            Item = value
        };
    }

A similar question has been asked on a Microsoft forum almost a year ago, but no answer yet. http://social.technet.microsoft.com/Forums/en-NZ/exchangesvrdevelopment/thread/c4d6bbb9-ba6a-4aa4-9e39-98a52b733a8c

I was hoping SO would be more successful :)

Thanks, Jeffry

1

1 Answers

0
votes

I thought the two methods were equivalent as long as you used publicstrings (which it looks like you do). How about using MFCMAPI to see the difference in what's generated?