Importing an Email Attachment using the IMAP Connector icon

Importing an Email Attachment using the IMAP Connector

(0 reviews)

home

Learn how to use the IMAP connector to transfer information via email.


Screenshot of the main flow in Anypoint Studio, view full image here

Description

This example shows you how to use the IMAP connector to facilitate information transfer through email. It also illustrates how you can use the datamapper to transform a CSV file to XML.

Example Use Case

In this example a CSV file containing sample sales data which has been received as an attachment in an email inbox is imported using the IMAP connector. The Datamapper then converts the CSV file to the XML format. The logger then logs this data on the studio console.

Set Up and Run this Example

  1. Open the project in the studio interface

  2. Click on the IMAP Connector in the Mule flow and edit its properties as follows:

        imap.server=imap.googlemail.com
        imap.port=993
        imap.user=receiveremailaddress%40gmail.com
        imap.password=receiver_password
  3. Run the project as a Mule application

  4. Navigate to src/main/resources to find the input.csv file. Use any email address to send the 'input.csv' file as an attachement to receiveremailaddress@gmail.com

  5. If you have configured and run this example correctly, the csv file should appear in the xml format in the studio console. The log message should be similar to what is show below:

      INFO  2014-07-07 10:39:43,897 [[imap-to-xml].imap-to-csvFlow1.stage1.02]
      org.mule.api.processor.LoggerMessageProcessor: recieved: <?xml version="1.0" encoding="UTF-8"?>
        < orders>
        < order>
        < orderId>1< /orderId>
        < name>aaa< /name>
        < units>2.0< /units>
        < pricePerUnit>10< /pricePerUnit>
        < /order>
        < /orders>
        < orders>
        < order>
        < orderId>2< /orderId>
        < name>bbb< /name>
        < units>4.15< /units>
        < pricePerUnit>5< /pricePerUnit>
        < /order>
        < /orders>
  6. After processing the attachment, it will be saved in src/tests/resources/output folder with xml format.

Documentation

Read full documentation in GitHub

Examples to Try Next

If you understood this example
Querying a Database and Attaching Results to an Email - Learn how to query a MySQL DB, aggregate the results and attach them as a CSV to an email.View
If you struggled with this example
Import Contacts Into Salesforce - Learn how to take a CSV file of contacts and upload them to Salesforce.View

Reviews

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

Asset versions for 1.3.x

Asset versions
VersionActions
1.3.3