AI Summary
Key points of this article, generated by AI.
Generating AI Summary
You are interacting with an AI system. AI-generated responses may not always be accurate or complete. Please verify important information before relying on it.
Coforge: Where AI engineering meets industry expertise.
Learn about our company, our vision and values, and the 45,000+ professionals enabling businesses to harness the power of AI.
Learn more about Coforge
Learn about our company, our vision and values, and the 45,000+ professionals enabling businesses to harness the power of AI.
Learn more about Coforge
Coforge: Where AI engineering meets industry expertise.
Learn about our company, our vision and values, and the 45,000+ professionals enabling businesses to harness the power of AI.
Learn more about Coforge
Learn about our company, our vision and values, and the 45,000+ professionals enabling businesses to harness the power of AI.
Learn more about Coforge
BLOG | Email Generation (with Attachment) using Form Component
AI Summary
Key points of this article, generated by AI.
Generating AI Summary
You are interacting with an AI system. AI-generated responses may not always be accurate or complete. Please verify important information before relying on it.
Learn to create a custom form component which takes user input and on submit would send an email with an attached pdf which would contain the data entered in the form.
A custom form component will be built taking user input in the form field. A Sling Servlet will be built which would be creating a pdf in the content DAM Structure and attaching the same pdf to the custom email.
- Create a component under /apps//components.
- sample_form is the component.

- Create the node cq:dialog and file sample_form.html under the component.

- Add the below code in the sample_form.html.

- Now, open wknd repo in any of the IDE and create a Servlet under wknd.core package.
- For the Servlet code, you can refer to the following URL :
- Now, go to http://localhost:4502/system/console/configMgr
- Search for Day CQ Mail Service(day.cq.mailer.DefaultMailService).
- Update the configurations according to required SMTP server. Below screenshot can be used as reference.
- Update SMTP Server, Port, Username, Password, from details. Below SMTP Server host name is used for testing purpose.
- Actual hostname can be configured as required.

- Make sure your SMTP Server is up.
- Once the code is deployed to the Server, create a sample page and add the component to the Page.
- The page would look as below

- Enter the values in the form and click on Button. You can see in the network tab, a request is triggered.
- On Click of Button, 2 actions will be performed.

Once, you get the success response with the Http Status as 200 OK. Check your email, you must have received an email.

- You can find the pdf content as below. You can modify the pdf content through the code in which format user would like to display.

- Also, once you click on Button, the corresponding pdf is also stored in AEM DAM.

- User can store the PDF in any of the path under/content/dam
Hope you liked the article. Please reach out to digital group: digital.interactive@coforge.com for any query.
WHAT WE DO
Explore our wide gamut of digital transformation capabilities and our work across industries
Email Generation (with Attachment) using Form Component
Voice is AI-Generated. Inconsistencies may occur.
You are interacting with an AI system. AI-generated responses may not always be accurate or complete. Please verify important information before relying on it.
When you use the “Coforge AI” on our website, the information you enter in the chat (“prompts”) is processed to generate responses to your queries about Coforge and the content available on our website.
For more information about how Coforge processes personal data when you visit or interact with our website, please refer to our Global Privacy Statement.