Issue
- When a user uploads a file through a Liferay Legacy Form, the notification email is sent, but the uploaded file is not included as an attachment.
- Is there a way to include a file uploaded through a Liferay Form as an attachment in the notification email?
Environment
- Liferay DXP 2023.Q4+
Resolution
Attaching a file from a legacy form submission directly to the notification email is not supported and would require custom development.
However, this functionality can be achieved using Liferay Objects as an alternative. The following steps outline the process:
-
Create an Object:
- Define a new custom Object to store the form data.
- See: Creating and Managing Objects.
-
Add Fields to the Object:
- Add the necessary fields to the Object, including a field of the type "Attachment" to handle file uploads.
- See: Creating and Managing Objects: Fields.
-
Create a Form for the Object:
- Associate a form with the Object using either of the following methods:
- Using Form Fragments. See: Creating Forms Using Form Fragments.
- Directly from the Object's interface. See: Using Forms with Objects.
- Associate a form with the Object using either of the following methods:
-
Create a Notification Template:
- Design a custom email notification template. In this template, the content of the "Attachment" field should be included as a file attachment in the email.
- See: Creating Notification Templates.
-
Define an Object Action:
- Configure an action for the Object that triggers upon form submission (i.e., when a new Object is added). This action should send an email using the previously created custom notification template.
- See: Defining Object Actions.