Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Download POP3 Email using UIDLsDemonstrates how to download POP3 email by first getting the complete set of UIDLs and then downloading email by calling FetchEmail for each UIDL. This is equivalent to calling CopyMail, except your application can process each email as it arrives instead of waiting for the entire bundle to be downloaded. Also, it's better protection against potential out-of-memory issues if your mailbox has a very large number of messages. There is no performance difference between fetching emails individually vs. calling CopyMail.
import com.chilkatsoft.*; public class ChilkatExample { static { try { System.loadLibrary("chilkat"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load.\n" + e); System.exit(1); } } public static void main(String argv[]) { // The mailman object is used for receiving (POP3) // and sending (SMTP) email. CkMailMan mailman = new CkMailMan(); // Any string argument automatically begins the 30-day trial. boolean success; success = mailman.UnlockComponent("30-day trial"); if (success != true) { System.out.println("Component unlock failed"); return; } // Set the POP3 server's hostname mailman.put_MailHost("mail.chilkatsoft.com"); // Set the POP3 login/password. mailman.put_PopUsername("myLogin"); mailman.put_PopPassword("myPassword"); CkStringArray sa; sa = mailman.GetUidls(); if (sa == null ) { System.out.println(mailman.lastErrorText()); return; } int i; int n; n = sa.get_Count(); CkEmail email; String uidl; for (i = 0; i <= n - 1; i++) { uidl = sa.getString(i); email = mailman.FetchEmail(uidl); if (email == null ) { System.out.println(mailman.lastErrorText()); break; } System.out.println(email.ck_from()); System.out.println(email.subject() + "\r\n"); } mailman.Pop3EndSession(); } } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.