質問

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