In one of my previous tutorials, I explained step by step how we can use Send Mail Activity from Mail Palette to send email from TIBCO BW process. This tutorials is an extension to that tutorial as I am going to explain in this tutorial how to send email from tibco process with multiple attachments.
Consider a scenario where some application X generates PDF files and places those PDF files in a directory. A process in TIBCO BW application checks for the files in that folder and then attaches all the PDF files and sends an email with multiple attachments.
Now let’s proceed step by step with this tutorial and see how we can send email with multiple attachments from a TIBCO designer process. Our Final Process will look like below screenshot:
Step 1: List PDF Files from the directory
For this tutorial, we are taking a directory into consideration where we have two PDF files already places. Create a Global Variable and save the path of that directory in the global variable.
Now use List Files activity from the Files Palette and in the input tab of this activity, map the global variable as shown below:
The directory which is specified in our Gobal Variable (C:\test\*) has two PDF files (ajmal.pdf and abbasi.pdf).
Step 2: Configure Send Mail Activity for Multiple Attachments
This is the key step of our tutorial. From Mail Palette, drag Send Mail activity in the process. In order to Send an email, you must have some SMTP Server access. For this scenario, I am using a free SMTP Server (by registering on smtpcorp.com). SMTP Host Name and User Name are being saved in Global Variables.
Send Mail configuration for my case is shown below:
Now move to the Input tab of Send Mail activity. Here we will map from and to email addresses from the Global Variables. Also specify some subject and body text for the email. In order to attach all the files listed through List File activity, use For-Each loop for the mimePart and map File Name to it. As our attachment is PDF, we specify application/pdf in the content type.
Complete input mapping for Send Mail activity is shown in below screenshot:
This completes all the required mappings and configurations of activities in our process. Now we will proceed to the next step in which we will run the process and test it.
Step 3: Run TIBCO Designer Process to Send Email with Attachments
Load the process in designer tester so that it starts automatically. As you can see in below screenshot, process has run successfully to its end without any error:
You can verify the email with attachments by going into the email address which was specified in the MAIL_TO global variable.
Hope this tutorial will be helpful for you. Feel free to comment/contact for any further help. Thanks