Thursday, September 30, 2010

Mailto Hyperlink with subject and Body with line breaks

After some trial and error here is sample code for a hyperlink mailto:

HyperLink surveyLink = new HyperLink();
surveyLink.Text = "Send Survey";
StringBuilder sBody = new StringBuilder();
sBody.Append("Please help us provide you with better service
by taking a moment to complete our short survey located at:
%0D%0A%0D%0A");
sBody.Append(surveyUrl + "%0D%0A%0D%0A");
sBody.Append("Thank You,%0D%0A%0D%0A");
sBody.Append("Support Team");
surveyLink.NavigateUrl = "mailto:" + "?subject=Survey&body="
+ Server.HtmlEncode(sBody.ToString()) + " %0D&0A";
placeholder1.Controls.Add(surveyLink);

No comments: