我有以下的代碼來創建和發送電子郵件:如何正文格式設置爲HTML在C#電子郵件
var fromAddress = new MailAddress("[email protected]", "Summary");
var toAddress = new MailAddress(dReader["Email"].ToString(), dReader["FirstName"].ToString());
const string fromPassword = "####";
const string subject = "Summary";
string body = bodyText;
//Sets the smpt server of the hosting account to send
var smtp = new SmtpClient
{
Host = "[email protected]",
Port = 587,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
我如何能在郵件正文設置爲HTML?
你也應該把'var smtp = new SmtpClient'放在'using'中。 –