(Unicode C++) Iterate Email Headers
Demonstrates how to iterate over the email header fields.
#include <CkEmailW.h>
void ChilkatSample(void)
{
CkEmailW 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(L"testReceivedHdrs.eml");
if (success != true) {
wprintf(L"%s\n",email.lastErrorText());
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 wchar_t *name = 0;
const wchar_t *value = 0;
for (i = 0; i <= n - 1; i++) {
name = email.getHeaderFieldName(i);
value = email.getHeaderFieldValue(i);
wprintf(L"%d\n",i);
wprintf(L"%s\n",name);
wprintf(L"%s\n",value);
}
}
}
|