I know there are a lot of question similar to this one but I cannot seem to find the right answer. So in my page I have CKEditorControl I want to use its content and send it as text. The problem is that the email is send with all the tags and they are not rendered put pasted as plain text.
public class MailSender
{
private readonly MailMessage mailMessage;
private SmtpClient smtpClient;
private string fromEmail = myMail;
private string fromPass = myPass;
public MailSender()
{
this.mailMessage = new MailMessage();
this.mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
this.mailMessage.BodyEncoding = Encoding.UTF8;
this.mailMessage.From = new MailAddress(MyMail);
}
public void Send(string subject, string body, params string[] to)
{
this.mailMessage.Body = body;
this.mailMessage.Subject = subject;
this.mailMessage.IsBodyHtml = true;
foreach (var mail in to)
{
this.mailMessage.To.Add(mail);
}
using (this.smtpClient = new SmtpClient("smtp.gmail.com", 25))
{
this.smtpClient.EnableSsl = true;
this.smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
this.smtpClient.UseDefaultCredentials = false;
this.smtpClient.Credentials = new NetworkCredential(this.fromEmail, this.fromPass);
this.smtpClient.Send(this.mailMessage.From.ToString(), this.mailMessage.To.ToString(), this.mailMessage.Subject, this.mailMessage.Body);
}
}
}
This is the class which is responsible for sending my emails.