I have just spent a quite some time trying to figure out why a .Net program I wrote to e-mail users some batch-generated reports would work on my box and not on the users’ machines. Lots of googling turned up exactly nothing, although others must have experienced the same thing.
The basic program has worked fine for a long time mailing a single PDF report, but now I wanted to add some additional HTML files as attachments. This resulted in the following message on the user PC’s:
Mailbox unavailable. The server response was: 5.6.0 Invalid header found (see RFC2822 section 3.6)
What I discovered is that the System.Net.Mail.MailMessage component happily submits .pdf files, .zip files, .txt files and probably a host of others – it’s apparently just .htm and .html files it that makes it (or the mail server?) unhappy!
So what was different? Well, it was the framework. As soon as a user PC hitherto running .Net 4.0 got the latest and greatest .Net Framework 4.5 installed everything was honky-dory and mails flew out over the wire.
Was this a feature or a flaw? Or was it the combination with a fairly restrictive mail-server? Hard to say – but at least my code is now working and I can get on with my life…