Skip to Content

CPI: Multiple attachments from different paths in one Mail

Hi Experts,

I have to report the failed and created invoices from the OData response and send them in one mail.

I have created the design and generated the CSV file as requested, but unable to attach both files in a single mail. Only Invoices created is coming in the mail.

As I don't want to create 2 emails for the same report I am looking for the suggestions for this urgent requirement.

Any pointers will be highly appreciated.

My iFlow design is as below:

Regards,

Pavan G

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Jul 01, 2020 at 06:41 PM

    Hello Pavan,

    Both the branches are independent as per your design. If you have used parallel multicast before splitting this into 2 branches then use join and gather so that you will get both the messages.

    It might need some more transformation if you use gather but as per my understanding it will give both the payloads.

    Regards,

    Sriprasad Shivaram Bhat

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 02, 2020 at 12:28 PM

    Hi

    use groovy script to add attachment.

    import com.sap.gateway.ip.core.customdev.util.Message;

    import org.apache.camel.impl.DefaultAttachment;

    import javax.activation.DataHandler;

    def Message processData(Message message)

    {

    String File = message.getProperty('FileName');

    String Filename = "";

    // 1: Construct a DataHandler object with CSV MIME type

    def dataHandler = new DataHandler(message.getBody(), "text/plain")

    // 2: Construct a DefaultAttachment object

    def attachment = new DefaultAttachment(dataHandler)

    Filename = "RESP" + File + ".csv"

    message.addAttachmentObject(Filename, attachment)

    return message

    }

    Add a comment
    10|10000 characters needed characters exceeded