(C++) Iterate Email Headers
Demonstrates how to iterate over the email header fields.
#include <CkEmail.h>
void ChilkatSample(void)
{
CkEmail email;
// First, load an email from a file.
// Note: an email object may be loaded from a file, or
// downloaded directly from a POP3 or IMAP server...
bool success;
success = email.LoadEml("testReceivedHdrs.eml");
if (success != true) {
std::cout << email.lastErrorText() << "\r\n";
return;
}
// How many header fields?
int n;
n = email.get_NumHeaderFields();
if (n > 0) {
// Display the name and value of each header:
int i;
const char *name = 0;
const char *value = 0;
for (i = 0; i <= n - 1; i++) {
name = email.getHeaderFieldName(i);
value = email.getHeaderFieldValue(i);
std::cout << i << "\r\n";
std::cout << name << "\r\n";
std::cout << value << "\r\n";
}
}
}
|