Lowercase headers generated by SmtpClient



In Emails generated via SmtpClient, the names of the headers, e.g. to, from,
subject, all seem to be in lower case. Although the RFC says that header
names are case-insensitive, there are some spam filters that block mail with
lower case headers. Also google desktop appears to ignore headers that are
all lower case.

The vast majority of mail I have seen names their headers with an initial
upper case, e.g. To, From, Subject. Looking with Reflector, it seems that
these names are buried rather deep in private or internal methods.

Does anyone know a workaround?



Walter Wang [MSFT]

Hi Mike,

Yes I can see there's an internal class Message has a method called
PrepareHeaders that is using lower case header names. I've also done some
further research and cannot see a supported way to override this headers

As you've already known, the header name should be case insensitive per the
RFC described; therefore the framework isn't doing anything wrong here.

If you still think it's a feature that we should add in future version of
.NET framework, please feel free to submit your feedback at
http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220 which
is monitored by our product team directly. Thank you for your understanding.

In the meanwhile, you can also contact those third party vendors' support
to see if there's a way to configure those tools to ignore header name

Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

This posting is provided "AS IS" with no warranties, and confers no rights.


Thanks for your prompt reply. You've confirmed my suspicions, but of course
that isn't the answer I wanted to hear.

I did go to the product feedback site you mentioned. The issue had already
been posted, and had received a few votes. One contributor mentioned that
this was a breaking bug in Eudora. Nonetheless, MS is standing behind the
RFCs and Closed the issue. sigh.

Contact the third parties, as you mentioned, seems pretty futile. We're not
talking about isolated, specialized interests, but major applications, e.g.
Eudora, Google Desktop, etc.

I think I will just reimplement Message/MailMessage, which seems like a big
pain, but I don't see any other way around the issue.





This worked for me...
If you have it, try your version of system.web.mail instead of system.net.mail - you'll get messages telling you it's obsolete - but it'll give you the headers you want.
You need to reference system.web.mail

System.Web.Mail.SmtpMail.SmtpServer = "mailrelay.trb"

Dim myMailMsg As New System.Web.Mail.MailMessage


myMailMsg.From = "(e-mail address removed)"
myMailMsg.To = "(e-mail address removed)"
myMailMsg.Subject = "test from dave"
myMailMsg.Body = "This is A Test Using the web.mail namespace"
myMailMsg.BodyFormat = Web.Mail.MailFormat.Text


Catch ex As Exception
MsgBox("Mail err " + ex.Message)
End Try

EggHeadCafe.com - .NET Developer Portal of Choice

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question