Blog Home  Home |  Breeze Home RSS 2.0 Atom 1.0 CDF  
Scott's Breeze Blog - RFID, BizTalk - MIME.FileName not populated
...and everything in between
 
 Tuesday, May 27, 2008

Today I was working on a BizTalk solution to intercept, transform, and relay emails sent from a LOB system. BizTalk polled a POP3 mailbox and my orchestration replaced the original plain/text email body with some fancy, template driven HTML content and sent it out a dynamic SMTP send port. Only the email body was to be modified, the rest of the email message was to replicate the original email message, including any attachments (that may or may not be present).

To aid in testing I wrote a simple .Net email client. (I got tired of composing a new email in Outlook every time I wanted to test the solution)

Breeze Simple Email Client

The solution worked well (and perhaps I may post about the details sometime later) accept for the fact the outbound message had lost the attachment filenames.

inbound showing attachment

outbound showing attachment

Note: The attachment on the outbound message has a filename of ATT00241.DAT smile_confused

A helper class in my orchestration inspected the inbound message for attachments and added them to the new outbound message. Each message part (attachment) was assigned the MIME message part context properties of the same inbound message part. What I found was the MIME.FileName property was not being populated by the MIME decoder.

The MIME decoder in the POP3 adapter (when configured to apply MIME decoding) populates the following message part context properties when a MIME encoded message is received:

MIME/SMIME Property Schema and Properties

I checked the message source of the email I was sending (via my DIY email client) to check the MIME headers were present.

incorrect message source

Appears OK right?...

content-type: application/octet-stream; name=SampleAttachment.zip
content-transfer-encoding: base64

Wrong smile_embaressed

It turns out the MIME decoder is looking for the content-disposition header values

content-type: application/octet-stream; name=SampleAttachment.zip
content-transfer-encoding: base64
content-disposition: attachment; filename=SampleAttachment.zip

So some quick changes to the Breeze Simple Email Client ...

attach.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment
attach.ContentDisposition.FileName = Path.GetFileName(attachmentFileName)

...and we were back to cooking with gas.

correct message source

and now attachments on our outbound message retain their original filename...noysh!

outbound showing correct attachment

And BTW, not all commercial email clients populate these MIME headers correctly either (or so a friend of a friend who's aunt once knew someone that was talking to a girlfriend at the supermarket said). Check out the message source of items in your inbox. You might be surprised. smile_regular

Happy spamming er...umm...BizTalking

5/27/2008 12:10:09 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [2]   BizTalk General  |  Trackback
5/30/2008 2:16:34 PM (AUS Eastern Standard Time, UTC+10:00)
Nice post Scotty - very descriptive! Certainly raising the bar yet again.
6/5/2008 4:56:00 PM (AUS Eastern Standard Time, UTC+10:00)
hi,

i am also facing the same problem as you.
can you please share the source code for your solution.

regards,

Amit
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Copyright © 2008 Breeze Training. All rights reserved.