Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Mirth Email Reader (http://www.mirthcorp.com/community/forums/showthread.php?t=11426)

phoff 08-27-2014 06:36 AM

Mirth Email Reader
 
I apologize if this has been answered before but I've searched this site for the answer and even online and have found it. The solution I did find just stated to use the Java mail API but didn't explain.

Can someone, please, point me to directions or tutorial on connecting to a POP3 mailbox, pulling the PDF attachment from the email, saving the PDF to a directory then deleting the email. I would settle just for a tutorial on using the email reader. I can't find this anywhere.

My initial thoughts were the following. I'm new to Mirth too, by the way.:D
  • Create an Email Reader Channel to connect to mailbox
  • Create a transformer to read the email and extract the PDF
  • Save the PDF data into the channelMap object
  • Set the Destination to FileWriter to write PDF

Obviously, I do not know how to accomplish this so ANY tutorial on using the EmailReader will be very helpful.

narupley 08-27-2014 06:56 AM

By default the Email Reader includes all message data:

http://i.imgur.com/9ND1a7j.png

That data will be serialized XML. In a transformer, you grab the attachment node (hopefully in Base64 format), and put it in a channel map variable. Then in the File Writer, drag that variable into your template, and make sure to use Binary mode.

phoff 08-27-2014 07:00 AM

thanks for the very quick answer. I wasn't expecting an answer anytime soon.
In your example, you use IMAP and not POP3. why?

narupley 08-27-2014 07:02 AM

Quote:

Originally Posted by phoff (Post 41734)
thanks for the very quick answer. I wasn't expecting an answer anytime soon.
In your example, you use IMAP and not POP3. why?

Those are just the default settings.

phoff 08-27-2014 07:08 AM

Ok. what if I switch to POP3. would the incoming stream be xml still?

narupley 08-27-2014 07:09 AM

Quote:

Originally Posted by phoff (Post 41738)
Ok. what if I switch to POP3. would the incoming stream be xml still?

Yep, the protocol doesn't change that.

phoff 08-27-2014 07:09 AM

thanks a lot!

phoff 08-27-2014 10:50 AM

for those looking for the complete solution, I'll post it here shortly.

lin_xd 12-25-2014 05:26 PM

where ? thanks.

phoff 12-26-2014 06:09 AM

sorry about that. I should have posted this a while back. I was building a channel that would extract a PDF attachment and write that PDF file to a pre-defined directory.

Source Tab - I used a POP3 Email Reader. I set the "Message Content" to All.
Click "Edit Transformer" - to create some templates

I created a new Mapper variable.
Variable: 'pdfData'
Mapping: msg['Attchment'].toString()

Destination Tab
Added 1 new destination called, "StoreInFolder". The connector type should be File Writer.

In the File Writer Settings section, I set the Template to the mapper variable I had created in the Source Tab. I set the value to $(pdfData).

Hopes that helps a little. I should had posted the solution when it was fresh in my mind.


All times are GMT -8. The time now is 01:04 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation