Thursday, April 21, 2011

MIME.FileName= "Blank" ??

Hi,
While working on an Integration to receive a file via email as attachment we normally use POP3 Adapter and MIME Decoder enabled So that the MIME Context fields are filled in properly. I googled on how does the POP3 Adapter populates it. This link helped me understand it better.
BizTalk uses the following logic to get the file name:
1. Take it from the Content-Description header. Some vendors don't populate the Content-Description header in the message sent to Exchange.
2. If not found, then the part name is based on the Content-ID header.
3. If still not found, then generate a GUID for the part name.

In our Scenario MIME.FileName was blank and the reason was the Mail Header was missing "content-disposition" field for Attachments.
Actual Header:
content-type: application/octet-stream; name=SampleAttachment.zip
content-transfer-encoding: base64
Expected Header:
content-type: application/octet-stream; name=SampleAttachment.zip
content-transfer-encoding: base64
content-disposition: attachment; filename=SampleAttachment.zip

Scott did shed some light on this issue out here
We had a discussion with the Vendor to populate content-disposition field for attachments in header but they were clear that their Mail Server guys will not accept this Change Request as the FileName is already available in ContentType field in the Mail header.Well actually the BizTalk MIME Decoder does populates it in "PartContentTypeSecondaryHeaderValue" .

So we handled it this way
if(MIME.FileName="")
filename = MIME.PartContentTypeSecondaryHeaderValue
I could not find much about this field.
Hope it helps you while working with FileNames in Mail Attachments.

Happy Integrating,
Nishil