locked
Sharing contract ignores the newline characters in the email body

    Question

  • Hi,

    I'd like to use the Sharing Contracts to share a text, and the target is the Built-In Mail client. 

    The problem is the Sharing Contract ignores the newline character. I already tried out the followings, but they did not work:

    "<br />,"

    "&#10;"

    "Environment.NewLine"

    Can anybody suggest else?

    Thanks

    Friday, February 14, 2014 8:54 AM

Answers

  • You can share the same content as text *and* HTML (with breaks):

    request.Data.SetText(textToShare);
    request.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(textToShare.Replace("\n", "<BR/>")));


    The Mail app will pick up the HTML.
    Friday, February 14, 2014 9:07 AM
  • Thanks!

    Meanwhile I applied the same as you suggested :)

    request.SetData(HtmlFormatHelper.CreateHtmlFormat(txt.Replace("\r\n", "<br />")));

    Only difference is I replaced the "\r\n" instead of just "\n".

    Thanks

    Friday, February 14, 2014 9:15 AM

All replies

  • You can share the same content as text *and* HTML (with breaks):

    request.Data.SetText(textToShare);
    request.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(textToShare.Replace("\n", "<BR/>")));


    The Mail app will pick up the HTML.
    Friday, February 14, 2014 9:07 AM
  • Thanks!

    Meanwhile I applied the same as you suggested :)

    request.SetData(HtmlFormatHelper.CreateHtmlFormat(txt.Replace("\r\n", "<br />")));

    Only difference is I replaced the "\r\n" instead of just "\n".

    Thanks

    Friday, February 14, 2014 9:15 AM