none
Saving A New Contact, Problem Trying To Add Content To Its Body RRS feed

  • Question

  • Hello,

    I am trying to create a new contact, assign a value to its body and then save the contact. However on the line :

    con.Body.Text = conValues["Body"];

    An Service Object Property Exception is thrown with the message "You must load or assign this property before you can read its value"

    Here's the code:

       CreateConnection();
    
       Dictionary<string, string> conValues = JSON.Deserialize<Dictionary<string, string>>(newContact);
    
       Contact con = new Contact(service);  
    
       con.Body.Text = conValues["Body"]; // This Line Throws "You must load or assign this property before you can read its value."
    
       con.Save();


    Is there a way to assign a value to the Contact's Body before saving?

     

    Thanks in advance


    Friday, June 24, 2011 2:43 PM

Answers

  • Hi,

    you need to assign the body differently:

    contact.Body = new MessageBody(BodyType.Text, conValues["Body"]);

    Kind regards,
    Henning

    "rbarr sandi" wrote in message news:1350c7fb-3cdb-4029-b464-1f9e6d08baa4@communitybridge.codeplex.com...

    Hello,

    I am trying to create a new contact, assign a value to its body and then save the contact. However on the line :

    con.Body.Text = conValues["Body"];

    An Service Object Property Exception is thrown with the message "You must load or assign this property before you can read its value"

    Here's the code:

      CreateConnection();
       Dictionary<string, string> conValues =
    JSON.Deserialize<Dictionary<string, string>>(newContact);
       Contact con = new Contact(service);
       con.Body.Text = conValues["Body"]; // This Line Throws "You must load or
    assign this property before you can read its value."
       con.Save();
     

     Is there a way to assign a value to the Contact's Body before saving?

    Thanks in advance

    • Marked as answer by rbarr sandi Monday, June 27, 2011 8:52 AM
    Friday, June 24, 2011 3:46 PM