After going through my step by step tutorials on how to use Send Mail activity in TIBCO designer to send an email and also how to send email with multiple attachments in TIBCO; some people asked me to write a tutorial on how to send a PDF as an attachment using TIBCO Send Mail activity. In this step by step tutorial; I am going to explain how we can send PDF documents as attachments from our TIBCO BW processes using SendMail activity.
We need to create a simple BW process which takes the name of a user as input and then based on that input; selects a particular PDF file and sends it as an email attachment to a particular email address.
Let’s proceed step by step with this tutorial.
Step 1: Create a Process with Start activity expecting a String Input
In TIBCO designer; create a new process. In the Start Activity Output Editor; add a new String Element to get UserName value as input as shown below:
Step 2: Add a Mapper for Choosing PDF File
For this example case; I have two pdf files already created with the names ajmal.pdf and abbasi.pdf. We need to choose the file based on the UserName that we receive as input of our start activity. For this purpose; I am adding a Mapper with a String Element named “FileName” in its input editor as shown below:
In the Input tab of this mapper; I have put the conditions to choose the file ajmal.pdf or abbasi.pdf based on the Input received as you can see in below screenshot:
Step 3: Configure Send Mail Activity to Send PDF attachments
This is the main step of our tutorial. From the Mail Palette; add Send Mail activity in the process. In the Configuration Tab; specify the SMTP host that you have rights to use. In the Input tab of Send Mail activity; specify Sender and Receiver Email addresses, Email subject. In the MimePart, content-type in the MimeHeaders should be “application/pdf” for sending PDF attachments. In the fileName, map the name of the file from the mapper output as shown below:
Step 4: Test the Process with Designer Tester
The last step is to test the process after validating it. Load the process in designer tester and run it by giving it input (if you input UserName as ajmal, you should receive ajmal.pdf as an attachment otherwise abbasi.pdf should be received).
I ran the process and I have received an email with PDF attachment in the inbox of the email address specified in “to” field of Send Mail activity input.