asp.net mvc aws sdk - 不呈现HTML电子邮件

时间:2013-03-23 17:46:42

标签: asp.net-mvc amazon

我正在使用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);
    }

电子邮件已发送,但它是纯文本格式。我做错了什么?

1 个答案:

答案 0 :(得分:0)

我发现了。 Gmail只是不支持样式标记。你必须把你的样式内联,直接放在div或table标签中。