Receiving MIME encoded email files and a hidden POP3 context property

Posted: August 12, 2009  |  Categories: BizTalk Uncategorized


Now that POP3 is not a part of Windows Server 2008 it is probably timely to post on a hidden POP3 adapter context property that you can use to decode emails picked up from the file system without actually using the POP3 adapter. I’ve been meaning to blog this for a while since I investigated it when reviewing a question on the MSDN forums. This trick is also useful for when you are using the POP3 Adapter but need to store the original email before any MIME decoding and then need to apply the decoding to it (in this case set the ‘Apply MIME decoding’ property on the POP3 adapter to false then use the method below later).

The POP3 adapter handles the POP3 protocol negotiation over TCP/IP to retrieve MIME encoded email messages. Once it has the email content, it puts it internally through an instance of the MIME/SMIME pipeline component (which in turn uses the COM dll BTSMIMEComps.dll) to decode it, and from there the message is given to the receive location pipeline.

The adapter writes (not promotes) an undocumented context property called CopyMailHeadersToContext to the message context before passing it to the MIME/SMIME pipeline component – this tells the component to add some POP3 properties to the message context as well.

So if you have MIME encoded emails being forwarded to BizTalk via file, FTP or otherwise (usually files with a .eml extension), you can reproduce the adapter’s behaviour by creating a very simple pipeline component to write the CopyMailHeadersToContext property with the POP3 adapter namespace and a value of 3 (don’t ask me why 3, still not sure about this value), then place it just before the MIME/SMIME pipeline component in the decode stage of a receive pipeline:


This is the execute method of the pipeline component, almost as simple as it gets:

public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
   //By writing this to the context we tell the MIME/SMIME decoder to
   //populate the POP3 context properties while going through the email message
   "", 3);
   return pInMsg;


Once the message goes through this pipeline you will then get some valuable properties in the context that you wouldn’t see with just the MIME/SMIME component. The properties are Date, From, Headers, Subject, and To:


And that’s it, pretty simple really :).

Download the sample here (Visual Studio 2008, BizTalk 2009)


Thiago Almeida

5 thoughts on “Receiving MIME encoded email files and a hidden POP3 context property”

  1. Whow,

    This is actually very cool. We use Mail for our incoming edi messages. Not having to use POP3 (with the concurrency problems if you have multiple receive hosts) is a real solution for us.

    Now we can just route the incoming mails with the smtp protocol to a file location.

    This saves us a lot of work !

  2. Hey Thiago,

    Long time!

    Is there a way to pass the message context (when using the pop3 adapter in my case) to a .net component? I want to retrieve the from,cc etc field in the .net component to form an xmldocument.


    1. Hi Dipesh, you would have to:
      – Get the values from the context inside a custom pipeline component or
      – Get the values from the context inside an orchestration and pass the values
      – Pass the entire BizTalk message to your .NET component (IBaseMessage in the pipeline component, XLangMessage in the orchestration) and get the values from the context in your .NET code

  3. how can i promote the message context properties of pop3 ? i would have to do the promotion after xml dissassembler ? and what will be the value of field in the argument object of pInMsg.Context.Promote( ,,Object) ?

Comments are closed.

BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More

Manage and monitor serverless
components effortlessly

Learn More
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top