This was a question (paraphrased) on the BizTalkGurus.com Forum: “How can I take email attachments and put them as is into a folder?”
When using the POP3 Receive Adapter, you have the ability to receive multiple items as attachments and the adapter will handle them using MIME processing. You do not need a custom pipeline.
When receiving a multi-attachment message, you have the ability to define one of the parts as the main message Body. If you leave the default (0), the email message body will be the main message Body and all attachments will be additional parts to the message.
Lets say you have 3 attachments and you want to receive in an email and write them out to disk in a folder location (you can always publish them to the message box and do anything you want with the messages). You could probably use a custom pipeline to break out the multi-part message into separate messages…
I found a very simple and straight forward approach to accomplish this task. The Orchestration looks like this:
The key is to create an Orchestration variable of type Microsoft.XLANGs.BaseTypes.XLANGMessage. In order to do this, you need to add a reference to Microsoft.XLang.BaseTypes.dll. Once you have this variable, you just need to set it equal to your input message like: oXMessage = In.
You now have access to everything the XLangMessage has available; most importantly Count and access to all the message parts. Now a simple loop can be used to loop over the parts and create new output messages for each message part.
The output messages are created like: Out = oXMessage[n] were n is the message part index (starting at 1 since 0 is the Body). It’s that simple. It’s a total of 4 lines of code inside the Expression Shape and Message Construct.
I have a sample solution available for download below.
Download: Splitting POP3 Email Attachments in BizTalk Server 2006
See the readme.txt file for set up information.
Steven,
Per my email –
Thanks very much for this example. I’ve been banging my new BTS head against the wall over this one.
I do have a questions as to how to get the resulting file(s) to be named as they were as attachments. Can you help? (IE resulting file names same as attachment names.)
Thanks,
Phil
You might want to check out this post: http://www.biztalkgurus.com/forums/viewtopic.php?t=1465
Hope this helps.
Hi,
I am very new to Biz talk. I downloaded application and deploy it successfully.
But when i create new receive location as per my mailid and server it gives error.
“Message-pop” could not be bound to “SampleEmailAttachment.splitEmail”.The Artifact “Message-pop” does not belong to same application as “SampleEmailAttachment.splitEmail” or its reference
Message-pop is my new receive location which i want to create.
Please guide me how to configure receive and send location
HI,
I have one problem using the SMTP Adapter.
When I asend the EMAIL I am getting Body aslo Attachment
I checked all Ways. But still coming same one more interesting Issue
when we are using the Outlook its coming Perfect, like attachemnt and boby.
when we are u sing exchange server its coming as switched wiith both boby and attachement
Hi Steven (and others),
I have an question:
I am able to recieve an e-mail in BizTalk Server 2010 with your solution.
The e-mail I receive is an reply to an e-mail we send to a e-mail adres that doesn’t exists (anymore).
Maybe the receiver has made a type mismatch in his e-mail adres, or anything like that.
I guess you get the idea.
Now i like to get the e-mail adres, where we originaly send the message to, from the reply message.
I have a message with 3 MIME-parts (Content type):
– text/html
– message/delivery-status
– massage/rfc822
How can I get the e-mail adres to where the e-mail was send originally?
Any help wil be welcome an appreciated.
Robbish.
hi ,
how can i extract email body text in a variable of orchestration ?
hi all
I have queries ,actually I am receiving mail from client mail like attached excel or body excel contain rows and columns how to convert these files into xml format pl help ..