static void Example1() { // If using Professional version, put your serial key below. ComponentInfo.SetLicense("FREE-LIMITED-KEY"); // Create POP client. using (var pop = new PopClient("<ADDRESS> (e.g. pop.gmail.com)")) { // Connect and sign to POP server. pop.Connect(); pop.Authenticate("<USERNAME>", "<PASSWORD>"); // Read the number of currently available emails on the server. int count = pop.GetCount(); Console.WriteLine(" NO. | DATE | SUBJECT "); Console.WriteLine("------------------------------------------------"); // Download and receive all email messages. for (int number = 1; number <= count; number++) { MailMessage message = pop.GetMessage(number); // Read and display email's date and subject. Console.WriteLine($" {number} | {message.Date.ToShortDateString()} | {message.Subject}"); } } }
} //end method public static void checkEmail() { ComponentInfo.SetLicense("FREE-LIMITED-KEY"); using (PopClient pop = new PopClient("pop.gmail.com")) { // Connect and sign to POP server. pop.Connect(); pop.Authenticate(Ref.email, Ref.password); // Read the number of currently available emails on the server. int count = pop.GetCount(); Console.WriteLine(" NO. | DATE | MESSAGE "); Console.WriteLine("------------------------------------------------"); // Download and receive all email messages. try { for (int number = 1; number <= count; number++) { GemBox.Email.MailMessage message = pop.GetMessage(number); // Read and display email's date and subject. Console.WriteLine($" {number} | {message.Date.ToShortDateString()} | {message.BodyText}"); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } }
static void Main() { // If using Professional version, put your serial key below. ComponentInfo.SetLicense("FREE-LIMITED-KEY"); using (PopClient pop = new PopClient("<ADDRESS> (e.g. pop.gmail.com)")) { pop.Connect(); pop.Authenticate("<USERNAME>", "<PASSWORD>"); // Get number of available messages. Console.WriteLine($"Mailbox message count: {pop.GetCount()}"); // Get size of all available messages in bytes. Console.WriteLine($"Mailbox size: {pop.GetSize()} Byte(s)"); } }
static void Main() { // If using Professional version, put your serial key below. ComponentInfo.SetLicense("FREE-LIMITED-KEY"); using (PopClient pop = new PopClient("<ADDRESS> (e.g. pop.gmail.com)")) { // Connect and login. pop.Connect(); Console.WriteLine("Connected."); pop.Authenticate("<USERNAME>", "<PASSWORD>"); Console.WriteLine("Authenticated."); // Check if there are any messages available on the server. if (pop.GetCount() == 0) { return; } // Download message with sequence number 1 (the first message). MailMessage message = pop.GetMessage(1); // Display message sender and subject. Console.WriteLine(); Console.WriteLine($"From: {message.From}"); Console.WriteLine($"Subject: {message.Subject}"); // Display message body. Console.WriteLine("Body:"); string body = string.IsNullOrEmpty(message.BodyHtml) ? message.BodyText : message.BodyHtml; Console.WriteLine(body); } }