Tavousi
Tavousi

Reputation: 15446

How to get the "Date" of an email?

I create an application that gets email from mail server. I use "System.Net.Mail.MailMessage" for receive email. Now I want to get "Date and Time" of each email that ins in Inbox.

Upvotes: 11

Views: 18489

Answers (2)

Mark
Mark

Reputation: 188

I inspected the MailMessageObject and found this:

  Headers=HeaderCollection(5) 
  {
    "Uid",
    "DateCreated",
    "DateReceived",
    "Date",
    "IsRead"

So that means you have a total of three options available to you. The output will be in string format.

message.Headers["DateCreated"];
message.Headers["DateReceived"];
message.Headers["Date"];

Upvotes: 1

Micah Armantrout
Micah Armantrout

Reputation: 6971

You will want to look at the emails headers here is some documentation

http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.headers.aspx

message.Headers["Date"];

Upvotes: 20

Related Questions