windows-8microsoft-metroshareemail-clientcharms-bar

How to add new line while sharing text in WinRt


I want to share some text using mail client on windows 8, in which I want to display new lines. It displays it correctly in notepad on using \r\n but doesn't work with the SetText function in DataTransferManager.


Solution

  • The key is to set text in HTML and not send it as string.

    Suppose the text you want to share is in string textToShare; Note that you will be sending a string in HTML, so you need to replace all new line characters with <br/>

    instead of

    theRequest.Data.SetText(textToShare);
    

    use

    theRequest.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(textToShare));