Importing an Email Attachment using the IMAP Connector

(0 reviews)

home

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

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 Anypoint Studio interface.
  2. Click 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 attachment 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 this: INFO 2018-07-07 10:39:43,897 [[imap-to-xml].imap-to-csvFlow1.stage1.02]org.mule.api.processor.LoggerMessageProcessor: received: <?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 is saved in src/tests/resources/output folder in XML format.

Reviews

TypeExample
OrganizationMuleSoft
Published by
MuleSoft Organization
Published onSep 6, 2018
Asset overview

Asset versions for 2.1.x

Asset versions
VersionActions
2.1.4
2.1.3