Sending a CSV File Through Email Using SMTP icon

Sending a CSV File Through Email Using SMTP

(0 reviews)

home

Shows how to use the SMTP connector to facilitate an information transfer through email. It also illustrates how you can use the File connector to input a CSV file and transform it using DataMapper.

screenshot from Anypoint Studio

Example

In this example, a CSV file containing sample sales data is stored in the local directory. This file is converted to the JSON format using DataMapper. The result is sent to an email address using the SMTP connector. DataMapper also computes the total price for each order by multiplying the unit price with the number of units. This example has been configured to use Google Gmail.

Set Up and Run this Example

  1. Open the project in Anypoint Studio.

  2. Create a folder called input under src/main/resources and paste the input.csv file into the input folder. Edit the path field in the file connector to:

     Path=src/main/resources/input
  1. Click the SMTP connector and configure its properties as follows:

     Host=smtp.gmail.com
     Port=587
     User=senderemailid%40gmail.com
     Password=senderpassword
    
     To=receiveremailid@gmail.com
     From=senderemailid@gmail.com
     Subject=Export from Excel
  2. Run the project as a Mule application.

  3. Login to receiveremailid@gmail.com to verify if the sales data was received via email. You should get an email that has the following content:

    [{orderId=1, name=aaa, units=2.0, pricePerUnit=10.0, totalPrice=20.0}, {orderId=2, name=bbb, units=4.15, pricePerUnit=5.0, totalPrice=20.75}]

Documentation

Read full documentation in GitHub


Reviews

TypeExample
OrganizationMulesoft Inc.
Published by
MuleSoft Organization
Published onMar 17, 2018
Asset overview

Asset versions for 1.4.x

Asset versions
VersionActions
1.4.0