An alternative to using the POP3 adapter to read email attachments – 2

Posted: December 30, 2008  |  Categories: BizTalk Uncategorized
Tags: BizTalk POP3

Why would you use anything else other than the POP3 adapter to consume email attachments in BizTalk? On Christmas eve I found a reason why you might want to use something else.

I was trying to finish a project where we receive un-typed documents as attachments via email and then do further processing on them. We used the a POP3 adapter to consume the emails. I tried one test to many. I attached the same attachment with the same file name to the email more than once. The POP3 adapter then fails abruptly on the receive port with something like;

“A message received by adapter “POP3” on receive location “Receive
UBF POP3” with
URI “POP3://EXCH.hooleydooleys.co.nz#KeyTest” is suspended.
Error details: Item has already been added. Key in dictionary: ‘Copy
of Bakery Instore Processed with 1month.xls’ Key being added: ‘Copy
of Bakery Instore Processed with 1month.xls’ ”

What is even worse it is not picked up by error routing on the port.
The error seems to suggest to me that the POP3 adapter does work with if multiple attachments have the same name.

The hour was getting late and I wanted to leave. I discovered that if you save the email to file as an eml file and then consume it with a file adapter using the MIME/SMIME decoder in a pipeline you can consume attachments with the same filename from an email. Thus the problem seems to be with the POP3 adapter.

I set up a SMTP server on the BizTalk server as described in a previous post, An alternative to using the POP3 adapter to read email attachments.

I created a custom decode pipeline to get the POP3.To, POP3.From and POP3.subject properties because the standard MIME/SMIME decoder does not capture the To: , From: or Subject: fields from an eml file. The custom decode receive pipeline component inherits from the MIME/SMIME decoder and also promotes values for POP3.To, POP3.From and POP3.Subject on the message. This did not take long because Kenny West has already described in detail how to do it (See  kennywest: Mime Decoder Pipeline Component in Biztalk 2004 (the solution)). Thanks Kenny I owe you one.

I added the new custom decode pipeline component to a new custom receive pipeline and configured it like so.

emldecoder2

Finally I created a file receive location that used the custom receive pipeline and used it to consume the eml files. I was happy I could finally go home for Christmas!

I’ll ask Microsoft whether they have a fix for this POP3 issue in the New Year but I was pleased that this workaround got me there in the end.

  • Pingback: Splitting Email attachments from the MIME decoder instead of the POP3 adapter « Connected Pawns()

  • guneet kalra

    hi ,

    how can i extract email body text in a variable of orchestration ?

    • mbrimble

      // Set the input message to a var of XLang Message type
      xlangContainer = MIMEMsg;

      // Note the n was initialized to 1 inside Variables

      // Get the n’th part and set to a new message
      EmailAttachment.MsgPart = xlangContainer[nIndex];

      // Add to count
      nIndex = nIndex + 1;

      //Execute a pipeline that has a pipleine component to process the body text and return your message
      //Example below

      CharsFromPartMsg = new System.Xml.XmlDocument();

      //Assume there is only one untyped MIME message
      untypedMIMEMsg = new Microsoft.XLANGs.Pipeline.SendPipelineInputMessages();

      untypedMIMEMsg.Add(EmailAttachment);

      Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteSendPipeline(typeof(Your.Pipelines.Snd_MIMEPartBody),untypedMIMEMsg,CharsFromPartMsg);

      //Do stuff with CharsFromPartMsg

BizTalk360
BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More
Serverless360
Azure

Manage and monitor serverless
components effortlessly

Learn More
Atomicscope
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top