BizTalk Server 2006 POP3 Adapter Usage


Spent a bit of time recently with the new POP3 adapter for BizTalk, and wanted to share some notes and screenshots.

I currently have a BizTalk solution that I’ve built on a VM for use in customer demos. I decided to add a POP3 receive location to an existing port
to see if I could use the same pipeline and architecture even when receiving email. So, first I added the new receive location …






Next, I configured the adapter. Few notes. The Apply MIME Decoding is great since you don’t have to use a pipeline to split the message up into
parts. Also, it throws a bunch of email-related fields into the context properties (see below for a screenshot). In my case, my attachment is a flat
file, so I set the content type to be text/plain. I also set the Body Part Index to 2. Why 2?
When the email message comes in, we create a multi-part message, with the email body as part 1, and attachment as part 2. If I had left this as 0, then
the adapter uses the following algorithm (text pulled from BizTalk 2006 help file …)

If the Body Part Index is set to 0 and the Body Part Content Type is blank then the following algorithm is used to select the BizTalk message body part:

  • Use the first MIME part with the Content-Description header set to “body”.
  • Otherwise use the first MIME part with the Content-Type header set to “text/xml”.
  • Otherwise use the first MIME part with the Content-Type header set to “text/plain”.
  • Otherwise use the first MIME part with the Content-Type header set to text/
  • Otherwise use the first MIME part.

Otherwise if the Body Part Index is set to 0 and the Body Part Content Type is set then the first body part of the incoming message that matches the
specified Body Part Content Type is selected as the BizTalk message body part. If there are no parts with a matching content type then the message
is suspended.



Otherwise if the Body Part Index is set to a value greater than 0 and the Body Part Content Type is blank then the body part with the specified index
is selected as the BizTalk message body part. If the specified index is greater than the number of body parts then the message is suspended.



Otherwise if the Body Part Index is set to a value greater than 0 and the Body Part Content Type is set then the Body Part Index is only applied to
those body parts that match the specified Body Part Content Type and the corresponding body part is selected as the BizTalk message body part. If
the specified index is greater than the number of parts with a matching content type then the message is suspended. If there are no parts with a
matching content type then the message is suspended.








Got all that? Then you just set all the appropriate security fields based on the type of authentication model (remember that the user name format
is different depending on the authentication choice). Next, I wrote a very simple .NET app that sends an email, plus attachment, to a chosen mailbox.








Here’s the cool stuff. The file processed exactly the same as if I had it submitted to the FILE adapter (which was the original means). Batch gets split
up into individual records, and pops back out the other side. But, if I set a breakpoint to check my message out that came in from the POP3 adapter,
I can see all the unique context properties that travel with my message …







Also, you’ll see that this is a multi-part message. One of the parts is the body of the email, the other, the content of the attachment. Note that if
I had chosen to turn Apply MIME Decoding off, then I would have gotten a single-part message, with the whole raw MIME message (headers, body, attachment).








So, POP3 adapter, neat stuff. Great that you don’t need yet another pipeline to parse it out, and that i can truly plug in as just another receive
location.

Comments (6)

  1. Mark Hudson says:

    Hi,  I’ve recently used the POP3 adaptor with a customer demo in exactly the same scenario as you.

    The "body part index" is a lot more powerful and complicated than the simple pair of text boxes would suggest.

    Its just another thing to learn/remember/puzzle over in the product we grow to love and respect BizTalk.

    PS

    Love your blog. Keep up the good work.

  2. Edmon Begoli says:

    Richard,

    Thank you for this entry.

    Can you give me a hint how should the POP3 adapter be configured to process e-mail messages where the content of the message is the body itself.

    i.e.

    Flat file is not attached – flat file is the body of the message itself.

    One more thing please – if I have a receive component in the orchestration what is the type of the receive pipeline I should use on the receive location.

    Many thanks,

    Edmon

  3. Hey Edmon,  you by no means have to have an attached message to interact with POP3 messages.  You can see above that when there is an attachment, it comes as a multi-part message, with one part being the email body content.  So, default handling dictates that received message bodies will be put into the message.  

    As far as the receive location, you don’t have to do anything fancy.  The MIME-decoding that’s part of the adapter takes care of reading the message.  You’d only apply a pipeline if you had some other sort of custom processing to do.

Skip to main content