Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Visual C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

 

 

 

 

 

 

 

Iterate and Display Email Header Fields

Example source code to iterate over an email's header fields and print each name/value pair.

// The Chilkat Mail library is also available as an ActiveX component
// or .NET class with the identical set of methods and properties.

// Iterate over an email's header fields.
void EmailExample(void)
    {
    CkString str;
    CkMailMan mailman;

    // Any string passed to UnlockComponent begins the 30-day trial.
    bool unlocked = mailman.UnlockComponent("30-day trial");
    if (!unlocked)
	{
	printf("Failed to unlock component\n");
	return;
	}

    // Set the POP3 port to the standard MS Exchange Server SSL POP3 port 995
    // mailman.put_MailPort(995);
    // Tell the mailman to connect to POP3 using SSL
    // mailman.put_PopSsl(true);

    mailman.put_MailHost("mail.chilkatsoft.com");
    mailman.put_PopUsername("matt");
    mailman.put_PopPassword(myPassword);

    // Copy email from the POP3 server.
    CkEmailBundle *bundle = 0;
    bundle = mailman.CopyMail();
    if (!bundle)
	{
	mailman.LastErrorText(str);
	printf("%s",str.getString());
	return;
	}

    int i;
    int n = bundle->get_MessageCount();

    for (i=0; i<n; i++)
	{
	CkEmail *email = bundle->GetEmail(i);

	printf("********* Email %d ***********\n",i);

	int numFields = email->get_NumHeaderFields();

	// Display each header field.
	int j;
	CkString strName;
	CkString strValue;
	for (j=0; j<numFields; j++)
	    {
	    email->GetHeaderFieldName(j,strName);
	    email->GetHeaderFieldValue(j,strValue);
	    printf("%s: [%s]\n",strName.getString(),strValue.getString());
	    }

	delete email;
	}

    delete bundle;

    return;
    }

 

 

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser