我正在使用 asw sdk 发送电子邮件。我在呈现电子邮件时遇到问题。电子邮件发送正常,但在电子邮件网络客户端(例如 Gmail)中,电子邮件是纯文本的。下面是我的代码:
string fileInfo = HttpContext.Current.Server.MapPath("~/Content/template.html");
string html = File.ReadAllText(fileInfo);
MailService.SendEmail(from, html, "Password reset", emails);
template.html 文件是经过验证的严格 html 文件。
发送电子邮件方法:
public static void SendEmail(string emailFrom, string emailBody, string emailSubject, List<string> toAddresses)
{
AmazonSimpleEmailServiceConfig amazonConfiguration = new AmazonSimpleEmailServiceConfig();
AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient("keyId","secretKey",amazonConfiguration);
Destination destination = new Destination();
destination.ToAddresses = toAddresses;
Body body = new Body() { Html = new Content(emailBody) };
Content subject = new Content(emailSubject);
Message message = new Message(subject, body);
SendEmailRequest sendEmailRequest = new SendEmailRequest(emailFrom, destination, message);
client.SendEmail(sendEmailRequest);
}
电子邮件已送达,但它是纯文本格式的。我究竟做错了什么?