Announcement

Collapse
No announcement yet.

Mirth Email Reader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.
    • 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.

  • #2
    By default the Email Reader includes all message data:



    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.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


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

      Comment


      • #4
        Originally posted by phoff View Post
        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.
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment


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

          Comment


          • #6
            Originally posted by phoff View Post
            Ok. what if I switch to POP3. would the incoming stream be xml still?
            Yep, the protocol doesn't change that.
            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment


            • #7
              thanks a lot!

              Comment


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

                Comment


                • #9
                  where ? thanks.

                  Comment


                  • #10
                    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.

                    Comment

                    Working...
                    X