(C#) Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached message). Note: This example requires Chilkat v11.0.0 or greater.
bool success = false;
Chilkat.Email email = new Chilkat.Email();
// Load an email from a .eml
success = email.LoadEml("embeddedEmail.eml");
if (success == false) {
Debug.WriteLine(email.LastErrorText);
return;
}
// Display how many attached emails are embedded within
// this one:
int numAttached = email.NumAttachedMessages;
Debug.WriteLine("numAttached = " + Convert.ToString(numAttached));
// Get the 1st attached message.
Chilkat.Email email2 = new Chilkat.Email();
success = email.GetAttachedEmail(0,email2);
if (success == true) {
// Display the subject, From, and a header field...
Debug.WriteLine(email2.Subject);
Debug.WriteLine(email2.From);
Debug.WriteLine(email2.GetHeaderField("X-SOMETHING"));
}
|