Together with other input text, from the form, I have to send an email and add the possibility of attaching a file coming from the DAM. How can I do it?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Vodjakxa ,
Using ACS AEM Commons EmailService, we can simplify the email-sending process in AEM as a Cloud Service (AEMaaCS) while maintaining best practices. The EmailService provided by ACS Commons allows us to send emails with dynamic variables and attachments easily. Read more: https://adobe-consulting-services.github.io/acs-aem-commons/features/e-mail/email-api/index.html
The sendMail(..) method now supports the following signature:
public List<String> sendEmail(String templatePath, Map<String, String> emailParams, Map<String, DataSource> attachments, String... recipients)
public List<InternetAddress> sendEmail(String templatePath, Map<String, String> emailParams, Map<String, DataSource> attachments, InternetAddress... recipients)
E-mail attachments can be passed in via the attachments parameter.
...
Map<String, DataSource> attachments = new HashMap<>();
String attachmentContentsAsString = "This text should be in the attache txt file."
attachments.put("attachment1.txt", new ByteArrayDataSource(attachmentContentsAsString, "text/plain"));
...
List<String> participantList = emailService.sendEmail(htmlEmailTemplatePath, emailParams, attachments, recipients);
Best regards,
Kostiantyn Diachenko.
Hi @Vodjakxa ,
Using ACS AEM Commons EmailService, we can simplify the email-sending process in AEM as a Cloud Service (AEMaaCS) while maintaining best practices. The EmailService provided by ACS Commons allows us to send emails with dynamic variables and attachments easily. Read more: https://adobe-consulting-services.github.io/acs-aem-commons/features/e-mail/email-api/index.html
The sendMail(..) method now supports the following signature:
public List<String> sendEmail(String templatePath, Map<String, String> emailParams, Map<String, DataSource> attachments, String... recipients)
public List<InternetAddress> sendEmail(String templatePath, Map<String, String> emailParams, Map<String, DataSource> attachments, InternetAddress... recipients)
E-mail attachments can be passed in via the attachments parameter.
...
Map<String, DataSource> attachments = new HashMap<>();
String attachmentContentsAsString = "This text should be in the attache txt file."
attachments.put("attachment1.txt", new ByteArrayDataSource(attachmentContentsAsString, "text/plain"));
...
List<String> participantList = emailService.sendEmail(htmlEmailTemplatePath, emailParams, attachments, recipients);
Best regards,
Kostiantyn Diachenko.
Asset data you can take using Asset API:
Asset asset = damResource.adaptTo(Asset.class);
InputStream is = asset.getOriginal().getStream();
Views
Replies
Total Likes
Views
Likes
Replies