TIBCO Send Mail Tutorial: How to Send Email With Multiple Attachments in TIBCO BW

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:

tibco send mail process 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:

tibco send mail list files input mapping

 

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:

tibco send mail with attachment configuration

 

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:

tibco send mail attachment input mapping 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:

tibco test send mail attachment screenshot

 

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

Ajmal Abbasi

Ajmal Hussain Abbasi is Integration Consultant By Profession with 13+ years experience in Integration domain mainly with TIBCO products. He has extensive practical knowledge of TIBCO Business Works, TIBCO Cloud, TIBCO Flogo, TIBCO Mashery, TIBCO Spotfire, EMS and TIBCO ActiveSpaces. He has worked on a number of highly critical integration projects in various sectors by using his skills in TIBCO Flogo, TIBCO API Management (Mashery), TCI, Tibco Designer, TIBCO Business Studio, Adapters, TIBCO EMS, RV, Administrator, TIBCO BE, TIBCO ActiveSpaces etc. Ajmal Abbasi has experience with MuleSoft ESB as well. Ajmal Abbasi is also experienced in the area of API Management particularly with WSO2 API management platforms. Ajmal Abbasi is also experienced in developing solutions using Core Java and J2EE Technologies. You can contact Ajmal Abbasi for Consultancy, Technical Assistance and Technical Discussions.

More Posts - Website - Facebook - LinkedIn - YouTube

25 thoughts on “TIBCO Send Mail Tutorial: How to Send Email With Multiple Attachments in TIBCO BW

  1. bhupendra

    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==”.

    Reply
  2. Saurabh Singh Negi

    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

    Reply
    1. Ajmal Abbasi Post author

      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

      Reply
      1. Saurabh Singh Negi

        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

        Reply
        1. Krishnarao

          I have tried to mapping the file but still getting the default file name..

          Thanks,
          krishna

          Reply
          1. Ajmal Abbasi Post author

            In the content-disposition if you specify the value as concat(“*;filename=”,”Ajmal.txt”)

            you will get the attachment with the name ajmal.txt

  3. Krishnarao

    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

    Reply
  4. Krishnarao

    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

    Reply
    1. Ajmal Abbasi Post author

      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

      Reply
  5. jyoti

    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

    Reply
  6. Andrew Walker

    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.

    Reply
    1. Ajmal Abbasi Post author

      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.

      Reply
  7. Alec

    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!

    Reply
    1. Ajmal Abbasi Post author

      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

      Reply
  8. Susmitha

    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.

    Reply
  9. Chandra

    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

    Reply
  10. Srini

    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

    Reply
  11. Sreeja

    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

    Reply
  12. Raghuveer

    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.

    Reply
  13. Subhashis Das

    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.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *