none
Body formatting lost when modifying meeting body before sending RRS feed

  • Question

  • I am adding some text in meeting body before sending the meeting.

    I am getting object of meeting as a parameter in 

    outlookUtils.outlookApplication.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(outlookUtils.outlookObject_ItemSend);
    Outlook.MeetingItem meeting

    but when i am adding something in meeting body 

     meeting.Body = "added text in body " + meeting.Body;
     meeting.Save();

    but we do not get html body in meeting.Body and when we append something in meeting body object and save meeting then the format of meeting body is lost. i.e. if there is any table in body then after sending the table is lost. if there is any link in body then the link is shown as text. 

    Can anyone help me with this????

    Monday, October 7, 2019 6:47 AM

All replies

  • Hello,

    The MeetingItem class doesn't provide any HTML related properties. Instead, you can use the following:

    MeetingItem.RTFBody - returns or sets a Byte array that represents the body of the Microsoft Outlook item in Rich Text Format.

    MeetingItem.Body - returns or sets a String representing the clear-text body of the Outlook item.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, October 7, 2019 2:30 PM
  • In theory, you can save the outgoing meeting request, then read and modify the PR_HTML MAPI property, but MeetingItem.PropertyAccessor might block that property (OOM wont' let you modify some "important" properties through the PropertyAccessor obejct).

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, October 7, 2019 3:41 PM
  • Hello Eugene, 

    Thanks for the help.

    By using Meeting.RTFBody i can add text in body of meeting without loss of format of body.(I understand that while forwarding the meeting the appended text is not there because i have added the text in meeting object and when we forward the meeting, it forward appointment, which we haven't  changed)

    But when i forward this received meeting and try to add text in this meeting while forwarding in the same way using Meeting.RTFBody then the format of body is lost.

    can you please help me with this???  

    once again, thanks for the help

    Wednesday, October 9, 2019 1:55 PM
  • Please remember that MeetingItem.RTFBody is a Byte array that represents the body of the Microsoft Outlook item in Rich Text Format. How do you set the property when forwarding it? Which code do you use for that?

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, October 9, 2019 3:02 PM
  • hello Eugene,

    i am adding a line of text at the end of body using following code.

    and the text is appended correctly and format of body is not lost.

    but if i forward this recieved mail and use same code to append the line then the body format is lost.(body contains a table and its lost after forwarding the meeting).

    am i missing something?? please help.

    StringBuilder strbuilder_body = new StringBuilder(); string message = meeting.RTFBody != null ? Encoding.ASCII.GetString(meeting.RTFBody) : ""; string[] str = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); string outlookmsgRich = "Appended text"; outlookmsgRich = stringInRtfFormat(outlookmsgRich); int findIndex = 0; for (int x = str.Length - 1; x >= 0; x--) { if (str[x].ToString().Contains(@"{\*\htmltag104 </div>}")) //to get the line on which last tag ends { findIndex = x; break; } } for (int x = 0; x < findIndex; x++) { strbuilder_body.AppendLine(str[x].ToString()); } strbuilder_body.AppendLine(outlookmsgRich); for (int x = findIndex ; x < str.Length; x++) { strbuilder_body.AppendLine(str[x].ToString()); } meeting.RTFBody = Encoding.ASCII.GetBytes(strbuilder_body.ToString()); meeting.save();

    ...................................................................................................

    private string stringInRtfFormat(string outlookmsgRich)
            {
                return @"{\*\htmltag64 <p {\htmlrtf0 " + outlookmsgRich + System.Environment.NewLine +
                      @"{\*\htmltag244 <o:p>}" + System.Environment.NewLine +
                      @"{\*\htmltag252 </o:p>}\htmlrtf\par}\htmlrtf0" + System.Environment.NewLine +
                      @"\htmlrtf \par" + System.Environment.NewLine +
                     @"\htmlrtf0" + System.Environment.NewLine +
                      @"{\*\htmltag72 </p>}";
            }





    Friday, October 11, 2019 5:48 AM
  • It seems you just don't get a well-formed RTF markup.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Friday, October 11, 2019 12:27 PM
  • what do you mean by well-formed RTF markup??? 

    Am i doing something wrong in code. what is the correct way to do it??

    Monday, October 14, 2019 6:26 AM
  • Your RTF data (at the very least) is missing <html> and <body> tags.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, October 14, 2019 10:41 AM