Hi Ranjana,
In the link you provided Maurice CGP Peters provided the fix for having multiple attachments and also getting any attachment file and not just text files.
Basically the issue seems to be with the use of UTF8 Encoding Scheme in the implmentation. You can check the following code provided by Marcus that does not use any Encoding Scheme and will handle multiple attachments as well:
public void Disassemble(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
{
var partName = string.Empty;
// we start from index 1 because index zero contains the body of the message
// which we are not interested
for (int i = 1; i < inmsg.PartCount; i++)
{
IBaseMessagePart currentPart = inmsg.GetPartByIndex(i, out partName);
Stream currentPartStream = currentPart.GetOriginalDataStream();
var ms = new MemoryStream();
IBaseMessage outMsg;
outMsg = pc.GetMessageFactory().CreateMessage();
outMsg.AddPart("Body", pc.GetMessageFactory().CreateMessagePart(), true);
for (int j = 0; j < inmsg.Context.CountProperties; j++)
{
string currentName;
string currentNamespace;
object obj = inmsg.Context.ReadAt(j, out currentName, out currentNamespace);
outMsg.Context.Write(currentName, currentNamespace, obj);
if (inmsg.Context.IsPromoted(currentName, currentNamespace))
{
outMsg.Context.Promote(currentName, currentNamespace, obj);
}
}
currentPartStream.CopyTo(ms);
outMsg.GetPart("Body").Data = ms;
//Promote attachment file name
outMsg.Context.Write("ReceivedFileName", "schemas.microsoft.com/.../file-properties" , currentPart.PartProperties.Read("FileName", "schemas.microsoft.com/.../mime-properties" ));
_msgs.Enqueue(outMsg);
}
}
Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question
Rahul