C# Requires Chilkat v11.0.0+
C#
Read an attached email
See more Email Object Examples
Open forward-as-attachment.eml from the forwarding example. Read the cover note’s subject, then open each attached message and inspect its own headers and attachment count. This works even when the outer message has no ordinary files.
Chilkat C# Downloads
bool success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Chilkat.Email wrapper = new Chilkat.Email();
success = wrapper.LoadEml("forward-as-attachment.eml");
if (success != true) {
Debug.WriteLine(wrapper.LastErrorText);
return;
}
Debug.WriteLine("Cover note: " + wrapper.Subject);
if (wrapper.NumAttachedMessages == 0) {
Debug.WriteLine("No attached messages.");
return;
}
Chilkat.Email nested = new Chilkat.Email();
int i = 0;
while ((i < wrapper.NumAttachedMessages)) {
success = wrapper.GetAttachedEmail(i,nested);
if (success != true) {
Debug.WriteLine(wrapper.LastErrorText);
return;
}
Debug.WriteLine("Original author: " + nested.From);
Debug.WriteLine("Original subject: " + nested.Subject);
Debug.WriteLine("Files on the original: " + Convert.ToString(nested.NumAttachments));
i = i + 1;
}