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

5 comments:

  1. In biztalk you can't do an IF statement.. so I just used PartContentTypeSecondaryHeaderValue and it seems to be working perfectly.. thanks so much!

    Its amazing how hard it is to find information on this.. they really need to write it all out..

    ReplyDelete
    Replies
    1. Dan,
      You can use an if Statement in Expression Shape...only thing is it wont show up the intellisense.

      Delete
  2. I had a problem testing MIME.FileName when it doesn't actually exist, generating an exception.
    I also found systems capable of building emails where an attachment is part #0, and body text is part #1. Body text doesn't have a filename.
    My current model, which improved once I found the article above, is described at http://oneguydid.wordpress.com/2013/02/20/accept-email-attachments-via-biztalk/

    ReplyDelete
  3. Nishil ,

    Thanks a lot for providing this solution.
    Finding solution for this took lot of time and made me frustrating.

    Thanks a lot once again .

    ReplyDelete
  4. wow, great help solved my problem

    ReplyDelete