locked
Problem with sharing of text RRS feed

  • Question

  • Hi,

    I am using "Sharing" to send text (string) by email.

    the data I am sharing is created like this:

    string data = "Log Data\n" + "========\n";
    data += "Log Type   : " + log.LogType.ToString() + "\n";
    data += "Date/Time:   " + log.TimeStamp.ToString( "MM/dd/yy - HH:mm:ss" ) + "\n";
    data += "Result:      " + log.Result.ToString() + "\n";
    data += "Value1:      " + log.Value1 + "     Value2:      " + log.Value2 + "\n";
    data += "Note:        " + log.Note + "\n\n";  

    the data is prepared and sent in an email. However the "\n" is not interpreted correctly neither before I send (by the Windows 8 mail program) or the receiving side GMail.

    The data presented on the send side looks like this:

    Log Data ======== Log Type : ToDo Date/Time: 06/05/12 - 08:00:00 Result: Normal Value1: 170 Value2: 0 Note: note 1 

    The ShareTextHandler is like this:

    DataRequest request = e.Request;
    request.Data.Properties.Title = "Share Data: ";
    request.Data.Properties.Description = "Send Data to a email address";
    request.Data.SetText( data );

    Was the "\n" changed in Windows 8? or the SetText does something to remove it?

    EitanB





    • Edited by eitanb Friday, October 5, 2012 9:02 AM
    Friday, October 5, 2012 8:01 AM

Answers

  • no, but you need to use SetHtml

    var htmlFormat = Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat("<html>...");
    request.data.setHtmlFormat(htmlFormat);
    

    • Marked as answer by eitanb Friday, October 5, 2012 8:04 PM
    Friday, October 5, 2012 6:14 PM

All replies

  • no other problems will do it right.. its a bug in mail program. i reported earlier. Maybe use html format?
    Friday, October 5, 2012 9:05 AM
  • Hi,

    Not sure I understand this sentence: "no other problems will do it right"

    As to doing it with HTML:

    Tried some test data with HTML like this:

    private string PrepareShareData() { string CR = System.Environment.NewLine; string data = string.Empty; data += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Final//EN\">" + CR; data += "<html>" + CR; data += "<body>" + CR; data += "<p>" + CR; data += "Log Data" + "<br/>" + CR; data += "========" + "<br/>" + CR; data += "Line 1" + "<br/>" + CR; data += "Line 2" + "<br/>" + CR; data += "</p>" + CR; data += "</body>" + CR; data += "</html>" + CR; return data;

    }

    Did not work...

    Tried also:

            private string PrepareShareData()
                {
                string CR = System.Environment.NewLine;
                string data = string.Empty;
    
                data += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Final//EN\">";
                data += "<html>";
                data += "<body>";
                data += "<p>";
                data += "Log Data" + "<br/>";
                data += "========" + "<br/>";
                data += "Line 1" + "<br/>";
                data += "Line 2" + "<br/>";
                data += "</p>";
                data += "</body>";
                data += "</html>";
    
                return data;
                }

    did not work either....

    I did create a .HTML file with the notepad that worked:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN">
    <html>
    <body>
    <p>
    Log Data<br/>
    ========<br/>
    Line 1<br/>
    Line 2<br/>
    </p>
    </body>
    </html>

    Is there a mail problem with HTML too or my HTML is wrong?

    Thanks,
    EitanB




    • Edited by eitanb Friday, October 5, 2012 5:58 PM
    Friday, October 5, 2012 5:30 PM
  • no, but you need to use SetHtml

    var htmlFormat = Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat("<html>...");
    request.data.setHtmlFormat(htmlFormat);
    

    • Marked as answer by eitanb Friday, October 5, 2012 8:04 PM
    Friday, October 5, 2012 6:14 PM
  • Way too much work to go around Microsoft bug....

    Fixed it.

    Thanks,
    Eitan


    • Edited by eitanb Friday, October 5, 2012 8:06 PM
    Friday, October 5, 2012 8:04 PM