Posted by: techsavygal | November 24, 2006

How to extract email body and attachements using POP3 Adapter in BTS 2006!

Hi,

Many people have been asking me this question for a long time now…hence, check out my answer in my usergroup (http://groups.msn.com/BUG-i) as below:

 Using Encoded MIME message – By default, the encoded mime message is passed to your orchestration.You can get this message and then execute a series of Receive Pipelines in the orchestration to extract the different parts of the email message as explained below:

1) On your POP3 Receive Adapter, in the location properties :

Set the Apply MIME Decoding property = False

2) Next,

i) In a BizTalk Project, add a receive Pipeline (You can call it as RecvPipelineBody) and then drag a MIME/SMIME decoder from the toolbox into the Decode Section of the Receive Pipeline.

In the properties of the MIME/SMIME decoder, set the :
Body Part Index = 0

This will extract the Email Body part of the message.

ii) In the same BizTalk Project, add a receive Pipeline (You can call it as
RecvPipelineAttachment) and then drag a MIME/SMIME decoder from the toolbox into the Decode Section of the Receive Pipeline.

For the properties of the MIME/SMIME decoder, set the :
Body Part Index = 2

This will extract the Email Attachment part of the message

iii) Add an orchestration to the BizTalk project and then have it
Receive the initial Encoded message from the Receive Port/Location discussed
in step 1.
In the orchestration add a Expression shape with something like the below
to execute the receive Pipelines to extract out the different parts of the
Email message :

// First get the attachment.
vPipelineOutPutMessages =
Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(Mod1BizTalk.RecvPipelineAttachment), msgEmail);
vPipelineOutPutMessages.MoveNext();
construct msgAttachement
{
  msgAttachment = null;
  vPipelineOutPutMessages.GetCurrent(msgAttachment);
}

// Next get the body of the message
vPipelineOutPutMessages =
Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(Mod1BizTalk.RecvPipelineBody), msgEmail);
vPipelineOutPutMessages.MoveNext();
construct msgBody
{
   msgBody = null;
   vPipelineOutPutMessages.GetCurrent(msgBody);
}

For more information on how to execute this receive pipeline in an orchestration, check the code sample in BizTalk Server 2006 SDK named “ComposedMessageProcessor” (path = C:\Program Files\Microsoft BizTalk Server
2006\SDK\Samples\Pipelines\ComposedMessageProcessor)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: