C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

POP3 Verify DKIM Signatures

Download the email from a POP3 mailbox and verify each DKIM or DomainKey signature.

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

//  The mailman object is used for receiving (POP3)
//  and sending (SMTP) email.
Chilkat.MailMan mailman = new Chilkat.MailMan();

//  Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    textBox1.Text += mailman.LastErrorText + "\r\n";
    return;
}

//  We'll also be needing the Chilkat DKIM object.
//  The Chilkat DKIM functionality is included in the "Chilkat MIME" license.
Chilkat.Dkim dkim = new Chilkat.Dkim();

success = dkim.UnlockComponent("30-day trial");
if (success != true) {
    textBox1.Text += dkim.LastErrorText + "\r\n";
    return;
}

//  Set the POP3 server's hostname
mailman.MailHost = "mail.cknotes.com";

//  Set the POP3 login/password.
mailman.PopUsername = "admin@cknotes.com";
mailman.PopPassword = "myPassword";

//  First, get the complete set of UIDLs for the email in the POP3 mailbox:
Chilkat.StringArray saUidls = null;
saUidls = mailman.GetUidls();
if (saUidls == null ) {
    MessageBox.Show(mailman.LastErrorText);
    return;
}

//  Download each email into a byte array
//  If DKIM signature verification is to be performed,
//  it is important to download the email exactly as-is.
int i;
byte[] mimeBytes = null;

int k;
bool bVerified;
int numDkimSigs;
int numDomainKeySigs;
for (i = 0; i <= saUidls.Count - 1; i++) {
    mimeBytes = mailman.FetchMime(saUidls.GetString(i));

    //  Verify each DKIM signature, if any exist.
    numDkimSigs = dkim.NumDkimSignatures(mimeBytes);
    for (k = 0; k <= numDkimSigs - 1; k++) {
        bVerified = dkim.VerifyDkimSignature(k,mimeBytes);
        if (bVerified == true) {
            textBox1.Text += "DKIM signature "
                 + Convert.ToString(k) + " verified" + "\r\n";
        }
        else {
            textBox1.Text += "DKIM signature "
                 + Convert.ToString(k) + " invalid" + "\r\n";
            textBox1.Text += dkim.LastErrorText + "\r\n";
        }

    }

    //  Verify each DomainKey signature if any exist.
    numDomainKeySigs = dkim.NumDomainKeySignatures(mimeBytes);
    for (k = 0; k <= numDomainKeySigs - 1; k++) {
        bVerified = dkim.VerifyDomainKeySignature(k,mimeBytes);
        if (bVerified == true) {
            textBox1.Text += "DomainKey signature "
                 + Convert.ToString(k) + " verified" + "\r\n";
        }
        else {
            textBox1.Text += "DomainKey signature "
                 + Convert.ToString(k) + " invalid" + "\r\n";
            textBox1.Text += dkim.LastErrorText + "\r\n";
        }

    }

}


 

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

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

Email Component · XML Parser