Click here to Skip to main content
15,897,187 members
Articles / Programming Languages / C#

.NET POP3 MIME Client

Rate me:
Please Sign up or sign in to vote.
4.89/5 (53 votes)
8 Feb 2008CPOL9 min read 1.1M   6.8K   174  
This article provides an implementation of a POP3 MIME client using .NET 2.0 and C#.
using System;
using System.Collections.Generic;
using System.Text;

using Net.Mail;
using Net.Mime;

namespace NetPopMimeClient
{
    internal class Program
    {
        private const string PopServer = "pop.gmail.com";
        private const int PopPort = 995;
        private const string User = "";
        private const string Pass = "";

        private static void Main(string[] args)
        {
            using (Pop3Client client = new Pop3Client(PopServer, PopPort, true, User, Pass))
            {
                client.Trace += new Action<string>(Console.WriteLine);
                //connects to Pop3 Server, Executes POP3 USER and PASS
                client.Authenticate();
                //
                client.Stat();
                foreach (Pop3ListItem item in client.List())
                {
                    MailMessageEx message = client.RetrMailMessageEx(item);
                    Console.WriteLine("Children.Count: {0}", message.Children.Count);
                    Console.WriteLine("message-id: {0}", message.MessageId);
                    Console.WriteLine("subject: {0}", message.Subject);
                    Console.WriteLine("Attachments.Count: {0}", message.Attachments.Count);
                    client.Dele(item);
                }
                client.Noop();
                client.Rset();
                client.Quit();
            }

            Console.ReadLine();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions