Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top