문제

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