Unable to send multiple file attachments in Email using servlet (REST endpoint) | Community
Skip to main content
Level 2
November 13, 2023

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

  • November 13, 2023
  • 3 replies
  • 1275 views

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-forms-authoring/authoring-adaptive-forms-foundation-components/configure-submit-actions-and-metadata-submission/custom-submit-action-form.html?lang=en#file-attachments

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Adobe Employee
November 13, 2023

are you on cloud service?

Rohan0794Author
Level 2
November 13, 2023

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

Adobe Employee
November 13, 2023

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

 

kautuk_sahni
Community Manager
Community Manager
December 11, 2023

@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