none
How to add contact informations (title, website and notes) in Exchange 2010 ? [EWS] RRS feed

  • Question

  • Hi all,

     

    Today, i learn how to work with EWS to do a synchronization to Exchange 2010.

    My synchronization is about contacts and i try to set some informations without success.

    Especially, the "title", "Web Site" and "Notes" informations.

     

    I success for the other informations but, after read documentations and forums, didn't success with these 3 info.

     

    Here is my code : 

     

    ExchangeService service = ..... 

    Contact exchContact = new Contact(service);

    exchContact.NickName = contact["NickName"].ToString();

    exchContact.GivenName = contact["FirstName"].ToString();

    exchContact.MiddleName = contact["MiddleName"].ToString();

    exchContact.Surname = contact["LastName"].ToString();

     

    There is no Members like "Title" or "Website" and i try to work with ExtendedPropertyDefinition like (for the title) 

     

    ExtendedPropertyDefinition ep2 = new ExtendedPropertyDefinition(int.Parse("3A45",System.Globalization.NumberStyles.HexNumber), MapiPropertyType.String);

    exchContact.SetExtendedProperty(ep2, contact["Title"].ToString())

     

    I also try with a decimal or directly with an integer for the ExtendedPropertyDefinition Tag.

     

    Can someone help me ? :)

    Thanks 

     

    Wednesday, July 13, 2011 4:02 PM

Answers

  • Hi,

    here are the property definitions you need to use:
    private static readonly ExtendedPropertyDefinition TitleProperty = new ExtendedPropertyDefinition(0x3a45, MapiPropertyType.String);
    private static readonly ExtendedPropertyDefinition BusinessHomepageProperty = new ExtendedPropertyDefinition(0x3a51, MapiPropertyType.String);
    private static readonly ExtendedPropertyDefinition PersonalHomepageProperty = new ExtendedPropertyDefinition(0x3a50, MapiPropertyType.String);

    The notes field is actually the body of the contact:

    var contact = new Contact(service);
    contact.GivenName = "givenname";
    contact.Surname = "surname";
    contact.SetExtendedProperty(TitleProperty, "Dr.");
    contact.Body = new MessageBody(BodyType.Text, "notes");
    contact.Save(WellKnownFolderName.Contacts);

    Kind regards,
    Henning
      "IDW.Antho" wrote in message news:36ff4564-641d-4b4d-a5ca-64100791338b@communitybridge.codeplex.com...
    Hi all,

    Today, i learn how to work with EWS to do a synchronization to Exchange 2010.

    My synchronization is about contacts and i try to set some informations without success.

    Especially, the "title", "Web Site" and "Notes" informations.

    I success for the other informations but, after read documentations and forums, didn't success with these 3 info.

    Here is my code :

    ExchangeService service = .....

    Contact exchContact = new Contact(service);

    exchContact.NickName = contact["NickName"].ToString();

    exchContact.GivenName = contact["FirstName"].ToString();

    exchContact.MiddleName = contact["MiddleName"].ToString();

    exchContact.Surname = contact["LastName"].ToString();

    There is no Members like "Title" or "Website" and i try to work with ExtendedPropertyDefinition like (for the title)

    ExtendedPropertyDefinition ep2 = new ExtendedPropertyDefinition(int.Parse("3A45",System.Globalization.NumberStyles.HexNumber), MapiPropertyType.String);

    exchContact.SetExtendedProperty(ep2, contact["Title"].ToString())

    I also try with a decimal or directly with an integer for the ExtendedPropertyDefinition Tag.

    Can someone help me ? :)

    Thanks

    Wednesday, July 13, 2011 5:47 PM

All replies

  • Hi,

    here are the property definitions you need to use:
    private static readonly ExtendedPropertyDefinition TitleProperty = new ExtendedPropertyDefinition(0x3a45, MapiPropertyType.String);
    private static readonly ExtendedPropertyDefinition BusinessHomepageProperty = new ExtendedPropertyDefinition(0x3a51, MapiPropertyType.String);
    private static readonly ExtendedPropertyDefinition PersonalHomepageProperty = new ExtendedPropertyDefinition(0x3a50, MapiPropertyType.String);

    The notes field is actually the body of the contact:

    var contact = new Contact(service);
    contact.GivenName = "givenname";
    contact.Surname = "surname";
    contact.SetExtendedProperty(TitleProperty, "Dr.");
    contact.Body = new MessageBody(BodyType.Text, "notes");
    contact.Save(WellKnownFolderName.Contacts);

    Kind regards,
    Henning
      "IDW.Antho" wrote in message news:36ff4564-641d-4b4d-a5ca-64100791338b@communitybridge.codeplex.com...
    Hi all,

    Today, i learn how to work with EWS to do a synchronization to Exchange 2010.

    My synchronization is about contacts and i try to set some informations without success.

    Especially, the "title", "Web Site" and "Notes" informations.

    I success for the other informations but, after read documentations and forums, didn't success with these 3 info.

    Here is my code :

    ExchangeService service = .....

    Contact exchContact = new Contact(service);

    exchContact.NickName = contact["NickName"].ToString();

    exchContact.GivenName = contact["FirstName"].ToString();

    exchContact.MiddleName = contact["MiddleName"].ToString();

    exchContact.Surname = contact["LastName"].ToString();

    There is no Members like "Title" or "Website" and i try to work with ExtendedPropertyDefinition like (for the title)

    ExtendedPropertyDefinition ep2 = new ExtendedPropertyDefinition(int.Parse("3A45",System.Globalization.NumberStyles.HexNumber), MapiPropertyType.String);

    exchContact.SetExtendedProperty(ep2, contact["Title"].ToString())

    I also try with a decimal or directly with an integer for the ExtendedPropertyDefinition Tag.

    Can someone help me ? :)

    Thanks

    Wednesday, July 13, 2011 5:47 PM
  • Hello,

     

    Thanks for your help.

    I can now add the notes field, it's working.

     

    But i always have some troubles with the ExtendedPropertyDefinition.

    I declare and use them as you described to me but i didn't see there informations when i open my contact's details in Outlook and i cannot understand why.

     

    Do you think there is another way to resolve this problem ?
    I see that CompleteName class exist, but it's read-only.

     

    Thanks again for your time and your help.

     

     

     

     

    Thursday, July 14, 2011 8:19 AM
  • Hi,

    do you have problems with all extended properties? Please post your actual code..

    Kind regards,
    Henning

    "IDW.Antho" wrote in message news:697ecdc6-21c2-43db-a881-340b5db1bd29@communitybridge.codeplex.com...

    Hello,

    Thanks for your help.

    I can now add the notes field, it's working.

    But i always have some troubles with the ExtendedPropertyDefinition.

    I declare and use them as you described to me but i didn't see there informations when i open my contact's details in Outlook and i cannot understand why.

    Do you think there is another way to resolve this problem ?
    I see that CompleteName class exist, but it's read-only.

    Thanks again for your time and your help.

    Friday, July 15, 2011 5:49 AM