This blog will guide you through a seamless process of sending a PDF as an attachment in a project, complete with customised parameters. This essential functionality plays a pivotal role in communication via email.
Imagine scenarios in a SuccessFactors project, where sending a PDF attachment is crucial or transmitting sales orders and invoices. This configuration is widely employed in various mailing scenarios, highlighting its significance in communication.
So here in this scenario lets envision a seamless process where we craft an email dynamically, encompassing subject, recipient address, mail body, and a PDF file. The beauty lies in the ability to send these dynamic details without the need for manual adjustments in both the CPI iFlow and mail adapter configurations.
Rather than sending the PDF as a standalone entity, we opt for a more sophisticated approach. We elegantly dispatch not only the PDF but also the accompanying elements such as recipient address, subject, and mail body as integral components of the email.
So let’s dive into to the flow.
So here the way we transport the PDF is using the Base 64 encoded data of the PDF. Basically this allows you to transport binary over protocols.
We can get the Base64 encoded data of a PDF using CPI. Please find below a simple flow to get a Base64 encoded data.
Image1
Image2
Image3
Image4
Image5
Image6
Image7
In Message Body we use the stored Base64 encoded data by using the expression ${property.pdf}
Image8
Image9
https://help.sap.com/docs/cloud-integration/sap-cloud-integration/configure-mail-receiver-adapter
Here in this flow we have used the Connection configuration shown in the image below.
Image10
The Processing configuration of the Mail Adapter is shown in the image below.
Image11
Image12
{
"emailId" : "[email protected]",
"pdfname" : "Abc",
"pdf" : "USE THE BASE64 ENCODED DATA HERE",
"subject": "PDF as Attachment",
"body": "Hello,
I hope this email finds you well. Please find the PDF file in the attachment.
Thanks,
Name"
}
Here in “emailId” -> Use the recipient mail address and in “pdf” -> Use the Base64 Encoded Data (refer Image4)
Image13
Image14
In conclusion, I believe that this blog post has aimed to deliver essential knowledge into the way of dynamically sending PDFs as email attachments by seamlessly incorporating subject lines, recipient addresses, and mail bodies in the Mail Adapter. Hence we eliminate the need for constant configuration adjustments.
Thanks and Regards,
Gagan H L