1

I want to send email that has html tags as text

This is what I send

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

the mail is send but without the string "<script src = http://whatever.com type = text/javascript></script>" because its coming as html tag and I need it to be send as text.

Any idae anyone?
Thanks in advance

2 Answers 2

1

Three notes:

  • Why are you trying to send scripts in an email? They'll be blocked by default.
  • string script instead of string sctipt
  • '&lt;script src="http://whatever.com" type="text/javascript"&gt;&lt;/script&gt;'
Sign up to request clarification or add additional context in comments.

Comments

0

Use HtmlEncode

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

or

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.