In C# I have the following code:
body = body + ":::::" + Events.JSONToString();
body = System.Web.HttpUtility.HtmlEncode(body).Replace('\n', '^');
System.Diagnostics.Process.Start(
String.Format(
"mailto:foo@bar.com?Subject={0}&Body={1}", subject, body
)
);
This works, but there are too many characters that will throw it off and terminate the body text prematurely.
Is there a formatting/escape routine that could help me preserve the data (and ideally the formatting)?
Because you are making this part of a query string you need to use Uri.EscapeDataString(body)
instead of System.Web.HttpUtility.HtmlEncode(body)
.