我正在使用Amazon SES发送大量电子邮件。以下是我的代码:
public void sendMail(String sender, LinkedList<String> recipients, String subject, String body) {
Destination destination = new Destination(recipients);
try {
ACCESS_KEY = EmailSender.prop.getProperty("accessKey");
SECRET_KEY = EmailSender.prop.getProperty("secretKey");
Content subjectContent = new Content(subject);
Content bodyContent = new Content(body);
Body msgBody = new Body(bodyContent);
Message msg = new Message(subjectContent, msgBody);
SendEmailRequest request = new SendEmailRequest(sender, destination, msg);
AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);
AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient(credentials);
SendEmailResult result = sesClient.sendEmail(request);
System.out.println(result + "Email sent");
}catch(Exception e) {
System.out.println("Exception from EmailSender.java. Email not send");
}
我已经将我的HTML内容作为字符串赋值给变量“body”。
邮件发送成功。但我收到的是带有HTML格式的电子邮件。如何在邮件中发送HTML内容?更改代码中哪些部分可以解决这个问题?