質問

I am configuring my c# web api code to send an email using Amazon Ses api and i am successful in sending email but i run into problems with use of html tags inside body which do not get rendered in the received email. Below is sample code--

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);

The <br/> tags appear in my email and are not rendered.

The <br/> tags appear in my email and are not rendered.

Any Help ..?

役に立ちましたか?

解決

Oops silly error in my code in following section..instead of this

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

it should be this this

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

didn't have html there and hence my tags were not being rendered as HTMl.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top