2016-12-27 3 views
1

Ich möchte E-Mail senden, die HTML-Tags als Textasp.net wie E-Mail als Text mit HTML-Tags senden

hat Das ist, was ich

string sctipt = "<script src = http://whatever.com type = text/javascript></script>"; 
message.Body = string.Format("script:{0}", script); 

die E-Mail senden, aber ohne die Zeichenfolge "<script src = http://whatever.com type = text/javascript></script>" weil es als HTML-Tag kommt und ich es als Text senden muss.

Irgendwelche Idae irgendjemand?
Vielen Dank im Voraus

Antwort

1

Drei Noten:

  • Warum versuchen Sie Skripte in einer E-Mail zu schicken? Sie werden standardmäßig blockiert.
  • string script statt string sctipt
  • '&lt;script src="http://whatever.com" type="text/javascript"&gt;&lt;/script&gt;'
0

Verwenden HtmlEncode

string script = "<script src=\"http://whatever.com\" type=\"text/javascript\"></script>"; 
message.Body = Server.HtmlEncode(script); 

oder

message.Body = System.Net.WebUtility.HtmlEncode(script); 
Verwandte Themen