How to get the “Date” of an email?
-
13-12-2019 - |
Question
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.
Solution
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"];
OTHER TIPS
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"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow