C# Requires Chilkat v11.0.0+
C#
Trace the Received headers on a delivered message
See more Email Object Examples
Each relay prepends its Received field. Read the trace from top to bottom for newest to oldest, and interpret fields in light of the relays you trust. An unsent local draft can have no trace headers.
Chilkat 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 name = new Chilkat.StringBuilder();
int hops = 0;
int i = 0;
while ((i < email.NumHeaderFields)) {
name.SetString(email.GetHeaderFieldName(i));
if (name.ContentsEqual("Received",false) == true) {
hops = hops + 1;
Debug.WriteLine("Hop " + Convert.ToString(hops) + ": " + email.GetHeaderFieldValue(i));
}
i = i + 1;
}
Debug.WriteLine("Received fields: " + Convert.ToString(hops));