.NET Core C# Requires Chilkat v11.0.0+
.NET Core C#
Read the timestamp from the most recent Received header
See more Email Object Examples
Read the topmost Received field of a delivered message. Its timestamp follows the final semicolon. A draft can have no trace header, and some relays supply an unparseable timestamp.
Chilkat .NET Core C# Downloads
bool success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Chilkat.Email email = new Chilkat.Email();
success = email.LoadEml("received.eml");
if (success != true) {
Debug.WriteLine(email.LastErrorText);
return;
}
Chilkat.StringBuilder trace = new Chilkat.StringBuilder();
trace.Append(email.GetHeaderField("Received"));
if (trace.Contains(";",true) != true) {
Debug.WriteLine("No timestamp delimiter in the top Received field.");
return;
}
string stamp = trace.GetAfterFinal(";",false);
trace.SetString(stamp);
trace.Trim();
Debug.WriteLine("Relay timestamp: " + trace.GetAsString());
Chilkat.CkDateTime when = new Chilkat.CkDateTime();
success = when.SetFromRfc822(trace.GetAsString());
if (success != true) {
Debug.WriteLine("Failed: when.SetFromRfc822.");
return;
}
Debug.WriteLine("UTC: " + when.GetAsTimestamp(false));