Pregunta

I have a problem with formatting:

MailMessage mail = new MailMessage(" ", radTextBox_To.Text, 
    radTextBox_Subject.Text, textControl.Text);
SmtpClient client = new SmtpClient("smtp.mail.ru");
client.Port = 25;
client.Credentials = new System.Net.NetworkCredential("login", "password");
client.EnableSsl = true;
client.Send(mail);
MessageBox.Show("Mail Sent!", "Success", MessageBoxButtons.OK); 

The mail message is delivered as a regular text message (no pictures) although textControl.Text contains a picture, text, different fonts. When the message is received, it comes across as standard text.

¿Fue útil?

Solución

By default, the MailMessage.Body property would render as plain text. You can change it to HTML by adding the following line of code after your declaration and prior to sending:

mail.IsBodyHtml = true;

Reference: MailMessage.IsBodyHtml Property

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top