如何获得没有字符串截断的完整正文内容?

时间:2017-01-17 13:14:28

标签: c#

在asp.net中使用mailto选项
需要定义正文内容。邮件的正文内容包含&,引用',双引号"。在将字符串传递给body变量时,由于特殊字符,字符串会被截断。

那么在传递给mailto时如何在不截断的情况下格式化完整的文本?

此处单元格0表示gridview的超链接,gridview单元格中的第3个参数选择(包含单引号,双引号等)

((HyperLink)e.Row.Cells[0].Controls[0]).NavigateUrl = setMail("abc", "Welcome", "Device is showing \"NO APN SPECIFIED ON THE DEVICE\" on a sim card which is \"not-activated\" yet although there are data connection and customer is able to surf the internet with the error message.")

protected String setMail(string owner, string subject, string body)
{               
    string body_text = "Hi%20" + owner + "%0D %0D" + "Information: " + body + "%0D %0D";           

    return String.Format("mailto:{0}?subject={1}&body={2}", owner, subject, body_text);
}

1 个答案:

答案 0 :(得分:-2)

您应该在设定值的开头添加@字符

string stringvar = @"//\'sometext";