How do i attach image in email? I am using AWS SES Service to send email using JAVA – Spring Boot

huangapple go评论101阅读模式
英文:

How do i attach image in email? I am using AWS SES Service to send email using JAVA - Spring Boot

问题

  1. public void sendEmail(String to, String subject, String body) throws MessagingException {
  2. Properties props = System.getProperties();
  3. props.put("mail.transport.protocol", "smtp");
  4. props.put("mail.smtp.port", PORT);
  5. props.put("mail.smtp.starttls.enable", "true");
  6. props.put("mail.smtp.auth", "true");
  7. Session session = Session.getDefaultInstance(props);
  8. Message msg = new MimeMessage(session);
  9. MimeMultipart multipart = new MimeMultipart();
  10. MimeBodyPart messageBodyPart = new MimeBodyPart();
  11. // 设置邮件正文内容:
  12. messageBodyPart.setContent(body, "text/html");
  13. multipart.addBodyPart(messageBodyPart);
  14. // 添加图片:
  15. messageBodyPart = new MimeBodyPart();
  16. DataSource fds = new FileDataSource("Logo.png");
  17. messageBodyPart.setDataHandler(new DataHandler(fds));
  18. messageBodyPart.setHeader("Content-ID", "<image_01>");
  19. multipart.addBodyPart(messageBodyPart);
  20. // 将多部分内容设置为消息的内容:
  21. msg.setContent(multipart);
  22. // 设置其他属性:
  23. try {
  24. msg.setFrom(new InternetAddress(FROM, FROMNAME));
  25. } catch (UnsupportedEncodingException e) {
  26. e.printStackTrace();
  27. } catch (MessagingException e) {
  28. e.printStackTrace();
  29. }
  30. msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
  31. msg.setSubject(subject);
  32. Transport transport = session.getTransport();
  33. try {
  34. System.out.println("Sending...");
  35. transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);
  36. transport.sendMessage(msg, msg.getAllRecipients());
  37. System.out.println("Email sent!");
  38. } catch (Exception ex) {
  39. System.out.println("The email was not sent.");
  40. ex.printStackTrace();
  41. } finally {
  42. transport.close();
  43. }
  44. }

![project_structure][2]

![Error_Log][1]

  1. [1]: https://i.stack.imgur.com/lpRfS.png
  2. [2]: https://i.stack.imgur.com/VsWy5.png
  3. <details>
  4. <summary>英文:</summary>
  5. I have a Spring Boot application hosted on AWS. I am using AWS SES to trigger email. But i am lost as to how to attach an image using SES. I am using JAVA as application source code.The data are stored in the database but the email is not sent.:

public void sendEmail(String to, String subject, String body) throws MessagingException {
Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", PORT);
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.auth", "true");

  1. Session session = Session.getDefaultInstance(props);
  2. Message msg = new MimeMessage(session);
  3. MimeMultipart multipart = new MimeMultipart();
  4. BodyPart messageBodyPart = new MimeBodyPart();
  5. // the body content:
  6. messageBodyPart.setContent(BODY, &quot;text/html&quot;);
  7. multipart.addBodyPart(messageBodyPart);
  8. // the image:
  9. messageBodyPart = new MimeBodyPart();
  10. DataSource fds = new FileDataSource(
  11. &quot;Logo.png&quot;);
  12. messageBodyPart.setDataHandler(new DataHandler(fds));
  13. messageBodyPart.setHeader(&quot;Content-ID&quot;, &quot;&lt;image_01&gt;&quot;);
  14. multipart.addBodyPart(messageBodyPart);
  15. // add the multipart to the message:
  16. msg.setContent(multipart);
  17. // set the remaining values as usual:
  18. try {
  19. msg.setFrom(new InternetAddress(FROM, FROMNAME));
  20. } catch (UnsupportedEncodingException e) {
  21. // TODO Auto-generated catch block
  22. e.printStackTrace();
  23. } catch (MessagingException e) {
  24. // TODO Auto-generated catch block
  25. e.printStackTrace();
  26. }
  27. msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
  28. msg.setSubject(SUBJECT);
  29. Transport transport = session.getTransport();
  30. try {
  31. System.out.println(&quot;Sending...&quot;);
  32. transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);
  33. transport.sendMessage(msg, msg.getAllRecipients());
  34. System.out.println(&quot;Email sent!&quot;);
  35. } catch (Exception ex) {
  36. System.out.println(&quot;The email was not sent.&quot;);
  37. ex.printStackTrace();
  38. } finally {
  39. transport.close();
  40. }
  41. }
  1. ![project_structure][2]
  2. ![Error_Log][1]
  3. [1]: https://i.stack.imgur.com/lpRfS.png
  4. [2]: https://i.stack.imgur.com/VsWy5.png
  5. </details>
  6. # 答案1
  7. **得分**: 1
  8. **将图像嵌入电子邮件中,需要对代码进行一些更改。我使用了SES帐户、JavaMailGmail Web客户端测试了这些更改:**
  9. **使用内容ID方案(`cid:`)**
  10. 这是您的正文内容使用`cid`的方式:
  11. ```java
  12. static final String BODY = String.join(System.getProperty("line.separator"),
  13. "<html><head></head><body><img src=\"cid:image_01\"></html> <br>"
  14. + "Welcome to ABC and have a great experience.");

在此示例中,image_01 是我想要使用的任意标识符。当邮件显示时,cid: 方案意味着电子邮件客户端将在消息中查找Content-ID头,并使用该名称检索相关图像 - 但该名称需要用尖括号 &lt;&gt; 括起来以内联显示(如下所示)。

在此处查看更多信息 [这里][1]。

创建多部分 MIME 消息

您的 MimeMessage msg 对象需要以不同方式构建:

  1. Message msg = new MimeMessage(session);
  2. MimeMultipart multipart = new MimeMultipart();
  3. try {
  4. BodyPart messageBodyPart = new MimeBodyPart();
  5. // 正文内容:
  6. messageBodyPart.setContent(BODY, "text/html");
  7. multipart.addBodyPart(messageBodyPart);
  8. // 图像:
  9. messageBodyPart = new MimeBodyPart();
  10. DataSource fds = new FileDataSource("/your/path/to/logo.png");
  11. messageBodyPart.setDataHandler(new DataHandler(fds));
  12. messageBodyPart.setHeader("Content-ID", "<image_01>");
  13. multipart.addBodyPart(messageBodyPart);
  14. // 将多部分内容添加到消息中:
  15. msg.setContent(multipart);
  16. // 像往常一样设置其余的值:
  17. msg.setFrom(new InternetAddress(FROM, FROMNAME));
  18. msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
  19. msg.setSubject(SUBJECT);
  20. } catch (UnsupportedEncodingException | MessagingException ex) {
  21. Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
  22. }

在此示例中,我们构建了一个包含两部分的消息:

  1. 来自 BODY 的 HTML 内容。
  2. 图像。

在我的示例中,图像是文件系统上的一个文件 - 但您可以根据应用程序的需要以任何方式访问它(例如通过资源)。

注意在设置头文件时尖括号的使用(如前面所述):

  1. messageBodyPart.setHeader("Content-ID", "<image_01>");

现在您可以以通常的方式发送消息:

  1. try ( Transport transport = session.getTransport()) {
  2. System.out.println("Sending...");
  3. transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);
  4. transport.sendMessage(msg, msg.getAllRecipients());
  5. System.out.println("Email sent!");
  6. } catch (Exception ex) {
  7. Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
  8. }

关于 JavaMailSender 的说明

在您的代码中,您包含了这个:

  1. private JavaMailSender mailSender;

这是 Spring 对 JavaMail(现在是 JakartaMail)对象的封装。您在代码中没有使用这个对象。

考虑到您正在使用 Spring,我建议您先让上述方法运行起来,然后重构您的代码以利用 Spring 的邮件辅助工具函数。有很多关于这方面的指南和教程。

关于 SES 的说明

上述方法使用了亚马逊的 [SES SMTP 接口][2]。换句话说,在您的代码中不需要任何亚马逊 SDK 类。

这是我在测试这个答案中使用的方法(使用 SES 帐户)。

您当然可以查看 [这里][3] 和 [这里][4] 中所记录的另外两种方法 - 但是对于显示图像来说,这两种方法都不是必需的。


更新

有一个关于这一点的澄清问题:

  1. messageBodyPart.setHeader("Content-ID", "<image_01>");

文本 &lt;image_01&gt; 是您在 HTML 代码中引用图像的方式。因此,这就是为什么我的示例代码使用了这个:

  1. <img src=\"cid:image_01\">

您可以在这里使用任何标识符。在我的示例中,标识符 "image_01" 是指我的图像文件 "logo.png"。

但是请明确一点 - 在您的代码中确实需要包含 &lt;&gt;。它们不仅仅是我代码中的“占位符”,它们是您需要使用的语法的一部分。


但是请记住,如果您充分利用 Spring 和 Spring 邮件辅助函数,一切都可以变得更简单。

例如,以下是相同方法的 Spring JavaMailSenderMimeMessageHelper 版本:

  1. import java.io.UnsupportedEncodingException;
  2. import java.util.logging.Level;
  3. import java.util.logging.Logger;
  4. import javax.activation.DataSource;
  5. import javax.activation.FileDataSource;
  6. import javax.mail.MessagingException;
  7. import javax.mail.internet.MimeMessage;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.mail.javamail.JavaMailSender;
  10. import org.springframework.mail.javamail.MimeMessageHelper;
  11. import org.springframework.stereotype.Component;
  12. @Component
  13. public class MySpringMailer {
  14. static final String FROM = "donotreply@myaddress.com";
  15. static final String FROMNAME = "My Name";
  16. static final String TO = "my.email@myaddress.com";
  17. static final String SUBJECT = "Welcome to ABC";
  18. static final String BODY = String.join(System.getProperty("line.separator"),
  19. "<html><head></head><body><img src=\"cid:image_01\"></html> <br>"
  20. + "Welcome to ABC and have a really great experience.");
  21. @Autowired
  22. private JavaMailSender javaMailSender;
  23. public void sendSpringEmailWithInlineImage() {
  24. MimeMessage msg = javaMailSender.createMimeMessage();
  25. try {
  26. MimeMessageHelper helper = new MimeMessageHelper(msg, true); // true = multipart
  27. helper.setFrom(FROM, FROMNAME);
  28. helper.setTo(TO);
  29. helper.setSubject(SUBJECT);
  30. helper.setText(BODY, true); // true = HTML
  31. DataSource res = new FileDataSource("c:/tmp/logo.png");
  32. helper.addInline
  33. <details>
  34. <summary>英文:</summary>
  35. To embed an image into your e-mail, you need to make a couple of changes to your code. I tested these changes using an SES account, JavaMail and a gmail web client:
  36. **Use the Content ID Scheme (`cid:`)**
  37. Here is your body content using a `cid`:

static final String BODY = String.join(System.getProperty("line.separator"),
"<html><head></head><body><img src=&quot;cid:image_01&quot;></html> <br>"
+ "Welcome to ABC and have a great experience.");

  1. In this example, `image_01` is whatever identifier I want to use. When the mail is displayed, the `cid:` scheme means that the email client will look for a `Content-ID` header in the message, and retrieve the related image using that name - but the name will need to be enclosed in angle brackets `&lt;` and `&gt;` to be displayed inline (see below).
  2. See more info [here][1].
  3. **Create a Multipart Mime Message**
  4. Your `MimeMessage msg` object will need to be built differently:

Message msg = new MimeMessage(session);
MimeMultipart multipart = new MimeMultipart();
try {
BodyPart messageBodyPart = new MimeBodyPart();
// the body content:
messageBodyPart.setContent(BODY, "text/html");
multipart.addBodyPart(messageBodyPart);
// the image:
messageBodyPart = new MimeBodyPart();
DataSource fds = new FileDataSource("/your/path/to/logo.png");
messageBodyPart.setDataHandler(new DataHandler(fds));
messageBodyPart.setHeader("Content-ID", "<image_01>");
multipart.addBodyPart(messageBodyPart);
// add the multipart to the message:
msg.setContent(multipart);
// set the remaining values as usual:
msg.setFrom(new InternetAddress(FROM, FROMNAME));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
msg.setSubject(SUBJECT);
} catch (UnsupportedEncodingException | MessagingException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}

  1. Here we build a message consisting of two parts:
  2. 1) The HTML contents from `BODY`.
  3. 2) The image.
  4. In my example, the image is a file on the filesystem - but you can access it in whatever way you need for your application (e.g. via a resource).
  5. Note the use of angle brackets when setting the header (as mentioned earlier):

messageBodyPart.setHeader("Content-ID", "<image_01>");

  1. Now you can send the message in the usual way:

try ( Transport transport = session.getTransport()) {
System.out.println("Sending...");
transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);
transport.sendMessage(msg, msg.getAllRecipients());
System.out.println("Email sent!");
} catch (Exception ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}

  1. **A Note on `JavaMailSender`**
  2. In your code, you include this:

private JavaMailSender mailSender;

  1. which is Spring&#39;s wrapper around the JavaMail (now JakartaMail) object. You don&#39;t make use of this object in your code.
  2. Given you are using Spring, I would recommend you get the above approach working, and then refactor your code to make use of Spring&#39;s mail helper utilities. There are lots of guides and tutorials for that elsewere.
  3. **A Note on SES**
  4. The above approach is using Amazon&#39;s [SES SMTP interface][2]. In other words, no need for any Amazon SDK classes in your code.
  5. This is what I used when testing the code in this answer (using an SES account).
  6. You can certainly look into using either of the other two approaches documented [here][3] and [here][4] - but neither is required for images to be displayed.
  7. ----------
  8. **Update**
  9. A question was asked, for clarification, about this:

messageBodyPart.setHeader("Content-ID", "<image_01>");

  1. The text `&lt;image_01&gt;` is how you refer to your image, in your HTML code. So, that is why my example code uses this:

<img src=&quot;cid:image_01&quot;>

  1. You can use any identifier you want here. In my case the identifier &quot;image_01&quot; refers to my image file &quot;logo.png&quot;.
  2. But just to be clear - you really do need to include the `&lt;` and the `&gt;` in your code. They are not there just as &quot;placeholders&quot; in my code - they are part of the syntax you need to use.
  3. ----------
  4. But remember, you can make everything much simpler, if you take full advantage of Spring, and the **Spring Mail Helper functions**.
  5. For example, here is the same approach, using Spring&#39;s `JavaMailSender` and `MimeMessageHelper`:

import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

@Component
public class MySpringMailer {

  1. static final String FROM = &quot;donotreply@myaddress.com&quot;;
  2. static final String FROMNAME = &quot;My Name&quot;;
  3. static final String TO = &quot;my.email@myaddress.com&quot;;
  4. static final String SUBJECT = &quot;Welcome to ABC&quot;;
  5. static final String BODY = String.join(System.getProperty(&quot;line.separator&quot;),
  6. &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;img src=\&quot;cid:image_01\&quot;&gt;&lt;/html&gt; &lt;br&gt;&quot;
  7. + &quot;Welcome to ABC and have a really great experience.&quot;);
  8. @Autowired
  9. private JavaMailSender javaMailSender;
  10. public void sendSpringEmailWithInlineImage() {
  11. MimeMessage msg = javaMailSender.createMimeMessage();
  12. try {
  13. MimeMessageHelper helper = new MimeMessageHelper(msg, true); // true = multipart
  14. helper.setFrom(FROM, FROMNAME);
  15. helper.setTo(TO);
  16. helper.setSubject(SUBJECT);
  17. helper.setText(BODY, true); // true = HTML
  18. DataSource res = new FileDataSource(&quot;c:/tmp/logo.png&quot;);
  19. helper.addInline(&quot;image_01&quot;, res);
  20. } catch (UnsupportedEncodingException | MessagingException ex) {
  21. Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
  22. }
  23. javaMailSender.send(msg);
  24. }

}

  1. So, for example, now we can create a reference for our image file using this:

helper.addInline("image_01", res);

  1. Note that Spring does not need us to use `&lt;` and `&gt;` here, when we are defining the name in our Java code. Spring takes care of that for us, behind the scenes.
  2. [1]: https://www.rfc-editor.org/rfc/rfc2392
  3. [2]: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-using-smtp.html
  4. [3]: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-using-sdk.html
  5. [4]: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-raw-using-sdk.html
  6. </details>
  7. # 答案2
  8. **得分**: 0
  9. 以下是用于通过SES发送电子邮件并将图像嵌入为附件的示例代码:
  10. ```java
  11. String filePath = "src/main/resources/" + barcodeText + ".png";
  12. System.out.println("barcodeImg was saved in System locally");
  13. String subject = "测试主题";
  14. String body = "<!DOCTYPE html>\n" +
  15. "<html>\n" +
  16. " <head>\n" +
  17. " <meta charset=\"utf-8\">\n" +
  18. " <title></title>\n" +
  19. " </head>\n" +
  20. " <body>\n" +
  21. " <p>测试</p>\n" +
  22. " <p>-- 来自附件的条形码<br><img src=\"cid:barcode\"></p><br>条形码渲染完成\n" +
  23. " </body>\n" +
  24. "</html>";
  25. String toAddrsStr = "emailID1, emailID2, emailID3";
  26. sendEmailWithAttachment(toAddrsStr, subject, body, filePath);
  27. **定义:**
  28. public static void sendEmailWithAttachment(String to, String subject, String body, String attachmentFilePath) {
  29. Session session = Session.getDefaultInstance(new Properties());
  30. MimeMessage message = new MimeMessage(session);
  31. try {
  32. message.setSubject(subject, "UTF-8");
  33. message.setFrom(new InternetAddress("gowthamdpt@gmail.com"));
  34. //to address String should be with comma separated.
  35. message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to));
  36. MimeMultipart msg = new MimeMultipart("alternative");
  37. MimeBodyPart wrap = new MimeBodyPart();
  38. MimeMultipart msgBody = new MimeMultipart("mixed");
  39. MimeBodyPart htmlPart = new MimeBodyPart();
  40. htmlPart.setContent(body, "text/html; charset=UTF-8");
  41. msgBody.addBodyPart(htmlPart);
  42. wrap.setContent(msgBody);
  43. msg.addBodyPart(wrap);
  44. MimeBodyPart att = new MimeBodyPart();
  45. DataSource fds = new FileDataSource(attachmentFilePath);
  46. att.setDataHandler(new DataHandler(fds));
  47. att.setFileName(fds.getName());
  48. att.setContentID("<barcode>");
  49. msg.addBodyPart(att);
  50. message.setContent(msg);
  51. AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard()
  52. .withRegion(Regions.US_EAST_1).build();
  53. message.writeTo(System.out);
  54. ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  55. message.writeTo(outputStream);
  56. RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
  57. SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage)
  58. .withConfigurationSetName(CONFIGSET);
  59. client.sendRawEmail(rawEmailRequest);
  60. System.out.println("sendEmail()" + "电子邮件触发成功");
  61. } catch (Exception ex) {
  62. System.out.println("sendEmail()" + "电子邮件未发送。错误:" + ex.getMessage());
  63. }
  64. }

注意:上述代码示例是关于如何使用Java发送电子邮件,并将图像作为附件嵌入。代码中的变量和方法可能需要根据您的实际情况进行适当的更改。

英文:

Here is a sample code for sending an email through SES with embed an image as an attachment:

  1. String filePath = &quot;src/main/resources/&quot; + barcodeText + &quot;.png&quot;;
  2. System.out.println(&quot;barcodeImg was saved in System locally&quot;);
  3. String subject = &quot;test subject&quot;;
  4. String body = &quot;&lt;!DOCTYPE html&gt;\n&quot; + &quot;&lt;html&gt;\n&quot; + &quot; &lt;head&gt;\n&quot; + &quot; &lt;meta charset=\&quot;utf-8\&quot;&gt;\n&quot;
  5. + &quot; &lt;title&gt;&lt;/title&gt;\n&quot; + &quot; &lt;/head&gt;\n&quot; + &quot; &lt;body&gt;\n&quot; + &quot; &lt;p&gt;test&lt;/p&gt;\n&quot;
  6. + &quot; &lt;p&gt;-- BarCode from attachment&lt;br&gt;&lt;img src=\&quot;cid:barcode\&quot;&gt;&lt;/p&gt;&lt;br&gt;BarCode render completed\n&quot;
  7. + &quot; &lt;/body&gt;\n&quot; + &quot;&lt;/html&gt;&quot;;
  8. String toAddrsStr = &quot;emailID1, emailID2, emailID3&quot;;
  9. sendEmailWithAttachment(toAddrsStr, subject, body, filePath);

Definition:

  1. public static void sendEmailWithAttachment(String to, String subject, String body, String attachmentFilePath) {
  2. Session session = Session.getDefaultInstance(new Properties());
  3. MimeMessage message = new MimeMessage(session);
  4. try {
  5. message.setSubject(subject, &quot;UTF-8&quot;);
  6. message.setFrom(new InternetAddress(&quot;gowthamdpt@gmail.com&quot;));
  7. //to address String should be with comma separated.
  8. message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to));
  9. MimeMultipart msg = new MimeMultipart(&quot;alternative&quot;);
  10. MimeBodyPart wrap = new MimeBodyPart();
  11. MimeMultipart msgBody = new MimeMultipart(&quot;mixed&quot;);
  12. MimeBodyPart htmlPart = new MimeBodyPart();
  13. htmlPart.setContent(body, &quot;text/html; charset=UTF-8&quot;);
  14. msgBody.addBodyPart(htmlPart);
  15. wrap.setContent(msgBody);
  16. msg.addBodyPart(wrap);
  17. MimeBodyPart att = new MimeBodyPart();
  18. DataSource fds = new FileDataSource(attachmentFilePath);
  19. att.setDataHandler(new DataHandler(fds));
  20. att.setFileName(fds.getName());
  21. att.setContentID(&quot;&lt;barcode&gt;&quot;);
  22. msg.addBodyPart(att);
  23. message.setContent(msg);
  24. AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard()
  25. .withRegion(Regions.US_EAST_1).build();
  26. message.writeTo(System.out);
  27. ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  28. message.writeTo(outputStream);
  29. RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
  30. SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage)
  31. .withConfigurationSetName(CONFIGSET);
  32. client.sendRawEmail(rawEmailRequest);
  33. System.out.println(&quot;sendEmail()&quot; + &quot;email triggered successfully&quot;);
  34. } catch (Exception ex) {
  35. System.out.println(&quot;sendEmail()&quot; + &quot;The email was not sent. Error: &quot; + ex.getMessage());
  36. }
  37. }

huangapple
  • 本文由 发表于 2020年8月28日 07:23:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/63625403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定