C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
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...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

POP3: Download Most Recent Email (method 1)

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

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

How to ready the N most recent email from a POP3 server.

The POP3 protocol does not provide the ability to request the most recent email, nor does it provide the ability to download email based on read/unread status or any other criteria. The design principle behind POP3 is that it is a temporary holding store for incoming email and email clients or other applications will transfer email from the POP3 server to a local persistent store where it will be managed. Therefore, POP3 does not provide sophisticated functionality (as opposed to IMAP which has the opposite design philosophy: that email is maintained and organized on the server).

This example shows one possible way to retrieve the N most recent emails from a POP3 server. It downloads the headers into a bundle object, then sorts the bundle by date, and finally retrieves the most recent emails by UIDL.

Another alternative is to download the UIDL list and then assume that the 1st N UIDLs are the most recent.

//  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) {
    MessageBox.Show("Component unlock failed");
    return;
}

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

//  Set the POP3 login/password.
mailman.PopUsername = "admin@chilkatsoft.com";
mailman.PopPassword = "*myPassword5*";

Chilkat.EmailBundle bundle;
//  Read mail headers and one line of the body.
bundle = mailman.GetAllHeaders(1);

if (bundle == null ) {
    MessageBox.Show(mailman.LastErrorText);
    return;
}

//  Sort the bundle by date
bool ascending;
ascending = false;
bundle.SortByDate(ascending);

//  Get the 10 most recent UIDLs
Chilkat.StringArray saUidls = new Chilkat.StringArray();
int i;
int n;
n = bundle.MessageCount;
if (n > 10) {
    n = 10;
}

Chilkat.Email email;
for (i = 0; i <= n - 1; i++) {
    email = bundle.GetEmail(i);
    saUidls.Append(email.Uidl);

}

//  Download in full the 10 most recent emails:
Chilkat.EmailBundle bundle2;

bundle2 = mailman.FetchMultiple(saUidls);
if (bundle2 == null ) {
    MessageBox.Show(mailman.LastErrorText);
    return;
}

for (i = 0; i <= bundle2.MessageCount - 1; i++) {
    email = bundle2.GetEmail(i);
    textBox1.Text += email.From + "\r\n";
    textBox1.Refresh();
    textBox1.Text += email.Subject + "\r\n";
    textBox1.Refresh();
    textBox1.Text += "----" + "\r\n";
    textBox1.Refresh();

}

 

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

Email Component · XML Parser