none
System.Net.Mail MailMessage date header in incorrecet format RRS feed

  • Question

  • When I create a new MailMessage and send it using SmtpClient the date headers appear of the email appear in an incorrect format. They appear as "6 May 2013 14:03:05 -0500" when they should look like "Mon, 6 May 2013 14:03:05 -0500".

    The best I can figure the date header is added during the SmtpClient.Send method and is not overrideable. 

    Does anyone know of a fix to address this specific issue? Any help would be greatly appreciated.

    Thank you.

    Edit: I am using .Net Framework 4.0



    • Edited by SixOThree Monday, May 6, 2013 7:13 PM added framework version
    Monday, May 6, 2013 7:08 PM

All replies

  • The SMTPClient doesn't add a time stamp.  The SMTPclient simply connects to a mail server and uploads the email message.  The server sends out the email to all parties.  It is the mail server that is formating the date header.

    jdweng

    Tuesday, May 7, 2013 3:24 AM
  • Thank you for the response, but as far as I can tell that is completely incorrect. I've sent to the mail server from different clients and the message headers arrive at the server unaltered.

    I was careful in saying the date header is added during the SmtpClient.Send() method, not by the SmtpClient; as best as I can tell it is set by System.Net.Message.

    SmtpClient.Send calls MailMessage.Send calls System.Net.Message.Send which performs a PrepareHeaders, during which it sets the Date header using MailBnfHelper.GetDateTimeString.

    Anyway.... According to rfc 2822 day-of-week is technically optional. But it would be great if I could just get it in there, saving me a tremendous amount of work.

    I don't think I'm going to find an answer here. In fact I'm pretty sure some jerk is going to mark your wildly incorrect response as an answer to my question. But you never know I suppose.

    Tuesday, May 7, 2013 3:56 AM