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 TIBCO Send Mail With Attachments tutorial 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.
Business Scenario:
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 Global 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
Recommended: How to Send Email Using Gmail SMTP in TIBCO BW6
hi
Thanks you for posting great articles.
I am getting error “.pdf is not a valid base64Binary. A valid example is AA==” while trying this example
Complete error
There is a binding error associated with activity. Send Mail
BWENGINE-100030 Job-77000 Error in [test/Process Definition.process/Send Mail]
Input data invalid
caused by: org.xml.sax.SAXException: validation error: data “F:\test\APPND-ANF-ENG-PART1.pdf” is not a valid base64Binary. A valid example is “AA==”. ({com.tibco.xml.validation}SIMPLE_E_INVALID_VALUE_FOR_TYPE) at /{http://www.tibco.com/namespaces/tnt/plugins/mail}mailActivityInput[1]/{http://xmlns.tibco.com/encodings/mime}mimeEnvelopeElement[1]/mimePart[1]/binaryContent[1]
com.tibco.xml.validation.exception.ValueParseException: data “F:\test\APPND-ANF-ENG-PART1.pdf” is not a valid base64Binary. A valid example is “AA==”.
change binarycontent –> to file name
Hello sir thank you for this great tutorial
what is the max size file (in MB)we can attach in mail.
Hi Sir,
Thanks for the tutorial.
I am able to send attachment through send email activity but attachment is coming with default name (ATT00001).
Can we get attachment with the mapped file name.
Thanks,
Saurabh
Dear Saurabh,
You can specify the attachment name in the field “contentDisposition”. Map file name to this field if you want actual file name to be used. Thanks
Hi Sir,
Thanks for the reply.
i have mapped the file name also but still getting the default name.
can you please help me out on this
Thanks,
Saurabh
I have tried to mapping the file but still getting the default file name..
Thanks,
krishna
In the content-disposition if you specify the value as concat(“*;filename=”,”Ajmal.txt”)
you will get the attachment with the name ajmal.txt
Hi Ajmal,
I have tried like as file name
here File name as complete path of the file
“C:\Test\sample.pdf”
tib:substring-after-last($Map-Data/FileName, “\”)
in this logic also will get the correct file path but while attachment getting the by default value
one more question:
in from email id as ..@gmail.com
to email id as …@Hotmail.com
in this case how the smtp host will work because only one host using in configuration tab
Thanks,
krishna
SMTP host specified in the configuration is meant for the sender and has nothing to do with the recipient email address. If you are sending email from gmail account; SMTP configurations should be for gmail irrespective of the “to” email address domain. Thanks
I am getting below error,
“BW-MAIL-100019 Job-142000 Error in [TestProcesses/Send Mail with Attachment.process/Send Mail With Attachment]
Error sending mail message. Cause: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect”
kindly help
You don’t have SMTP Host running locally in your machine on Port 25.
Hi Ajmal,
I am trying to have Tibco send two email attachments of different types. I have the list file activity giving me both the .Xml and .pdf files I need, however my problem is how to get two different mime types in a single email. I used an if-then-else logic to choose when to put ‘application/pdf’ or ‘application/xml’ but it is not working.
It is quite simple. You just duplicate mimepart by right clicking and choosing “duplicate” option. That way you will have two (or any number of attachments you want) mimeparts. Then in every mimepart, do the mappings and configurations as per your need. E.g. if your one attachment is pdf type; choose content type as application/pdf and if another attachment is of simple txt format; you can choose text/* in the content type.
Hi,
I am getting a “java.io.FileNotFoundException: (Access is denied)” error. I am sure the folder location is mapped correctly, and I have tried hard coding the file location (instead of global variables), but still does not work.
Is there a permission somewhere that needs to be set for TIBCO Designer to access this directory?
Thanks!
Dear Alec,
Make sure that file is accessible for the user which is running the designer. The best option for you to test is to run the designer with administrator user or else; change permissions of the file so that the user which you are using to run the designer is allowed access to the file. Thanks
hello,
I am retrieving data from Database table and in which one column data has comma..I am trying to send the table data as an csv attachment in send mail activity.I tried surrounding the specific column data with double quotes..But it is not working..the column data is being tokenised as multiple columns in the csv file.
It would be great if you can help me with this.
We are sending email with pdf attachement and HTML body.
we have provided configurations like below
content type: ‘text/html’;charset=’UTF-8′
but for Japanese and Hungarian languages , the default encoding is taking and mail is not as expected, unexpected data id adding the the body.
Please suggest me the content type or any other solution.
Thanks
chandra
I have developed a service to send an attachment and is working fine in designer. However, it is getting failed in admin/deployed mode.
Do i need any special configuration for this?
Error:
Error sending mail message. Cause: javax.mail.internet.ParseException
Message Code: BW-MAIL-100019
Please advise.
Thanks,
Srini
Hi,
My email attachment name contains umlaut character(Ó). While sending the mail send mail activity generates parse exception stating because it contains this character. I try to add different values in the content disposition to parse this…but its not working.Please help me in this
Hi,
how to give file attachment path after pushing this bw application to TIBCO Cloud Integration? I tried but it’s giving The system cannot find the file specified.
Thanks,
Raghuveer.
Error sending mail message. Cause: javax.mail.internet.ParseException: In parameter list < : addresses_sub_1.csv>, expected ‘;’, got “:”
getting this error while sending .csv as attachment.
Your csv file has issues. Make sure you have comma (,) as separator and not colon (:).