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.

Attach a pdf on fly in email after click on submit

Avatar

Community Advisor

Hi Guys,

I have one functionality where I have to click on submit button and generate email with attach a pdf.

- I am able to send the email.

- pdf contains dymanic content which is coming from API.

- this pdf is working fine. only need to attach it in email on fly or saving somewhere. and delete auto after sometime.

please help me in this.

Regards,
Prince Shivhare

5 Replies

Avatar

Level 10

Where are you keeping the pdf when once it has been populated with dynamic content?

Possible to share code snippet?

Avatar

Community Advisor

Hi Praveen,

we are able to generate the pdf. and able to attach it.

so its not necessary to do on fly. we can also save it for temp basis in crx and then delete.

for now we have kept one pdf in crx dam and attaching it. now our challenge is to save a pdf in dam dynamically. and delete after sometime.

and I have one more question here i.e if I will save it. will it create a rendition of it? because if pdf having 5 page. then it creates a 5 rendition. and we have to show original one.

Avatar

Level 10

Prince - why not create Java EMAIL API to send an email and then attach the PDF as an attachment.

JavaMail API - Sending Email With Attachment

Avatar

Community Advisor

Scott - code related to mail was already written by some other person. who is using MultiPart.

well I am able to send email and also in click on submit, I am able to save the attachment in dam folder.

and also able to send manually uploaded attachment with static path.

now only action required from my side is to attach the same pdf which will be downloaded in submit button. i.e dynamically getting the pdf. and then delete after sometime.

Avatar

Level 10

If that is an issue - look at writing the new service  that uses Java Email API and then have it attach the file.