0

我正在配置我的 c# web api 代码以使用 Amazon Ses api 发送电子邮件,并且我成功发送了电子邮件,但是我遇到了在正文中使用 html 标签的问题,这些标签没有在收到的电子邮件中呈现。下面是示例代码——

const String from = "team.avesta@gmail.com"; 
String to = "vinaynb@gmail.com";
String subject = "SLM ";
String body = GetMailBody(aMailType, aParams);

private static string GetMailBody(MailType aMailType, MailParams aParams)
      {
         string body = "";
         const string newline = ("<br/>");
         body += "Dear Admin," + newline;
         body += "Your UserName is:" + aParams.UserName + newline;
         body += "Your password is : " + aParams.Password + newline;
         body += "Website is: http://demo2dev.com/" + newline;
         return body;
}



Destination destination = new Destination(){ToAddresses = new List<string>() {to}};

Content emailSubject = new Content(){Data = subject};

Content textBody = new Content(){Data = body};

Body emailBody = new Body(){Text = textBody};

Message message = new Message(){Subject = emailSubject, Body = emailBody};

SendEmailRequest request = new SendEmailRequest(){Destination = destination, Source =from, Message = message};

AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient();

client.SendEmail(request);

标签出现在我的<br/>电子邮件中并且没有呈现。

<br/> 标签出现在我的电子邮件中并且未呈现。

任何帮助..?

4

1 回答 1

2

在下一节中我的代码中出现了愚蠢的错误..而不是这个

Body emailBody = new Body(){Text= textBody};

应该是这个这个

Body emailBody = new Body(){Html = textBody};

那里没有 html,因此我的标签没有被呈现为 HTMl。

于 2013-10-16T11:24:03.973 回答