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.

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top