3
I have a code in C# that sends emails with HTML, until then ok, the problem is that I can not send scripts (JS). Yes, I understand why, must be security reasons. But there is no way burlar
or do otherwise? -- With no malicious intent. My code:
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "xxx";
mail.Body = @"<script>SCRIPT aqui.</script>";
mail.IsBodyHtml = true;
using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
{
smtp.Credentials = new NetworkCredential("[email protected]", "xxx");
smtp.EnableSsl = true;
smtp.Send(mail);
}
}
As you asked if this cannot be done otherwise, what would be the function of the script?
– Sam
@dvd Just show an alert. I know I can display the message in HTML,but I wanted to run a
alert
in JS, just to see if it would work.– isaque
So, the email servers, for example Gmail, Hotmail and the like, for security don’t let any of that run, there’s no way around it, the only way, I see, would be to use some email receiver that doesn’t depend on these e-servicesmail, yes, because they use some kind of stripHtml when receiving the message, IE, your message arrives in any third party reader or others, already without these scripts! I believe it is a demand in vain, find alternatives!
– Marcus Rodrigues
@Draw what your goal is with this?
– Leandro Angelo