这是我的 C# 代码,它向给定的电子邮件地址发送电子邮件,它几乎可以正常工作但问题是我只得到文本作为标签,但背景中根本没有显示颜色(应该是 DodgerBlue ), 对为什么会这样有帮助吗?(我觉得可能是身体本身的问题。。。)
private bool SendEmail(string BodyText)
{
var fromAddress = new MailAddress("EmailIHave@gmail.com", "HackerOne Scanner");
var toAddress = new MailAddress("ToWhom@gmail.com", "Title");
const string fromPassword = "Password";
const string subject = "Important Update";
string body = "<h3 style=\"background - color:DodgerBlue; padding: 25px 25px 25px 25px; text - align: center; \">"+BodyText+"</h3>";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
try
{
message.IsBodyHtml = true;
smtp.Send(message);
return true;
}
catch
{
return false;
}
}
}
提前致谢。
猛跑小猪
相关分类