4 Replies Latest reply on Mar 15, 2013 9:00 AM by 847456

    Email polling with attachments

      Hello everyone,

      I'm facing a small trouble with the implementation of an OSB service.
      Our architecture consists on a OSB server (11gR1) acting as a facade, and then connects to a SOA server.
      Our objective is, through OSB, poll an email inbox to read the attachment of emails and process the data included in such attachments.
      We are currently processing the data correctly, however the first step - poll the email - it's not perfect.

      Right now we have a solution that is working.
      The proxy service polls the mail inbox (request message type: binary) and, as configured, sends the attachments to an archive folder where one other proxy service (protocol: file) polls the same folder to process the attachment.
      As I said before, this mechanism is working... However a lot of information is lost (email body, to, cc, bcc, date/time, etc...) and, if OSB allows an email protocol to receive requests, i sure believe that there must be a better way to process emails.

      I chose the request message type binary because if it was:
      - Text, the contents would be inside a CDATA container;
      - XML, i would get an error "Failure while unmarshalling message: Failed to parse XML text";
      - MFL, i wouldn't know the structure of the email to build the conversion file.

      Is there a way to process the email's attachments (binary, it is a .zip file) and, at the same time, read the remainder information contained?

      If you need any additional information about our architecture, or about the solution we implemented/want to implement, feel free to ask!

      Thanks in advance,
        • 1. Re: Email polling with attachments
          nothing...? Isn't this an easy thing to be done...?
          • 2. Re: Email polling with attachments
            Hi Bagagem,

            There is a sample here... But it is xml though...
            Text, the contents would be inside a CDATA container
            I reckon text should be the way to go, what's the problem with a CDATA container?

            The other info may to, cc, bcc will probably come in the headers... Go to the operational settings of your proxy server and enable message tracing with full detail level, then you can see on the osb server log exactly what is coming...

            Hope this helps...

            • 3. Re: Email polling with attachments
              Hey Vlad!
              Thanks a lot for your reply, i've been working on this, and I found the solution - mostly based on your tips :)

              I saw the link you gave before posting here, it has some useful information however the two most important things (in my work case) are missing...
              On one hand, the attachment - it doesn't have one. On the other, there's no reference on how to retrieve the header data (subject, to, cc, bcc, body,...).

              Just like you said, I changed the messaging request type to text. It really was the way to go.
              Then, in order to get the attachment, i sent this...
              ...to a java-callout, and encoded this Base64Binary to text. The code I used in this conversion was as follows:
              public static String encode(byte[] decoded){
                  return new String(org.apache.xmlbeans.impl.util.Base64.encode(decoded));
              And this was my main struggle, I was able to solve it in two simple steps :)

              The remainder information related to the email is very simple to obtain, as well.
              At first, I tried to retrieve the data from the $header variable, however such variable was empty of useful information...
              Such information it's actually at the $inbound variable,
              Once again, thanks for your reply!
              Best regards,
              • 4. Re: Email polling with attachments
                nice one.. spend a few hours to find a way to get the from and subject of the email.
                and simply by using the structure navigator on the left frame. my bad :(