Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Unable to send multiple file attachments in Email using servlet (REST endpoint)

Avatar

Level 2

Hello Community,
I was using the below code snippet provided by Adobe for getting multiple file attachments and sending an email using Email Service provided by ACS Commons:
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/forms/adaptive-form...

Map<String, DataSource> attachments = new HashMap<>();
for (Map.Entry<String, RequestParameter[]> param : req.getRequestParameterMap().entrySet()) {
RequestParameter rpm = param.getValue()[0];
logger.info("Param: {}", rpm);
if(!rpm.isFormField()) {
logger.info("Attachment found, content-type: {}", rpm.getContentType());
dataSource = new ByteArrayDataSource(rpm.get(), rpm.getContentType());
logger.info("Attachment: {}", rpm.getFileName());
// Create DataSource Map to attach all required set of files
attachments.put(rpm.getFileName(), dataSource);
} else {
logger.info("No attachment found!");
}
}


NOTE: Multiple attachments option is checked in Adaptive Form.
However, when I upload multiple attachments, I receive only a single document in the email received.
Checked logs - enters the if loop only once even though we upload multiple files.
Any idea what might be wrong?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Level 2

yes, on Cloud. 
Workflow is the only option to send multiple files?

Avatar

Employee

not necessary to use workflow. The article I sent was for 6.5

 

Avatar

Administrator

@Rohan0794 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni