Splitting Email attachments from the MIME decoder instead of the POP3 adapter

Posted: February 20, 2009  |  Categories: BizTalk Uncategorized

If you try to split email attachments that come from a custom pipeline that uses a MIME decoder then it is not easy to determine the file type. Recently I had to develop an alternative to the POP3 adapter that used the MIME decoder and found that I could not get the file name from the messages parts in the same way that i had got them from a POP3 adapter.Stephen Thomas has described in detail how to split email attachments using the POP3 adapter and I reproduce his orchestration below.

If you use the MIME decoder in a custom pipeline and leave the Body_part_index = 0 and the Body_part_content_type blank then the email body is the main message body and the attachments will be additional parts to the message in the same way as the POP3 adapter. They can be split be the same orchestration pattern as above.

I could not get the file name using the same code that was successful for the POP3 adapter i.e.

instead. My real question is what would I have done if i needed to get the file name? Does the message part have the file name somewhere?

attachmentXDoc = supplierEmail[attachmentNo];

supplierEmailPart = supplierEmail[attachmentNo];

 fileExtension = System.IO.Path.GetExtension(supplierEmailPart.Name);

// Set message properties

attachmentXDoc(FILE.ReceivedFileName) = System.IO.Path.GetFileNameWithoutExtension(supplierEmailPart.Name)+ System.Convert.ToString(attachmentNo) + fileExtension ;

In the case of the POP3 adapter the supplierEmailPart.Name is the file name of the email attachment. If you use the MIME decoder the supplierEmailPart.Name is a GUID. This is probably why the POP3 adapter throws an error if it tries top consume an email message that contains attachments with same file name whereas a pipeline that contains the MIMEdecoder consumes the same message without a concern.

I was lucky all i wanted to do was identify the file type so i just used code like

fileType = System.Convert.ToString(supplierEmailPart.GetPartProperty(typeof (Microsoft.XLANGs.BaseTypes.ContentType)));

What would I have done if I needed the file name? Does anyone know how to get the file name out of the message part or does it not exist?




BizTalk Server

Over 650+ customers across
30+ countries depend on BizTalk360

Learn More

Operate efficiently with enterprise-grade Azure monitoring,
tracing, remediation & governance in one platform

Learn More

Back to Top