Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 123,401 times

Contents

Related Categories

How to POP3 in C# - Using the Class

randy

Using the Class

Using the new class is pretty easy.

static void Main(string[] args)
{
    try
    {
        Pop3 obj = new Pop3();
        obj.Connect("mail.xxx.com", "yyy", "zzz");
        ArrayList list = obj.List();
        foreach (Pop3Message msg in list )
        {
            Pop3Message msg2 = obj.Retrieve(msg);
            System.Console.WriteLine("Message {0}: {1}",
                msg2.number, msg2.message);
        }
        obj.Disconnect();
    }
    catch (Pop3Exception e )
    {
        System.Console.WriteLine(e.ToString());
    }
    catch (System.Exception e)
    {
        System.Console.WriteLine(e.ToString());
    }
}

Instantiate a new object, then call the List method. The List method will return an array of Pop3Message objects. You can then iterate through the Pop3Message objects and retrieve each in turn. Finally, you call the Disconnect method to release the socket. POP3 is described in RFC 1939. You can read the full specification from the IETF website.

Randy's article are Copyright 1998-2003 Randy Charles Morin

Comments

  • Re: [4071] How to POP3 in C#

    Posted by mrymyousefii on 30 Jul 2008

    I got codes for receiving email from one of the article and made some necessary adjustments, but giving me this exception:


     


    System.Net.Sockets.SocketException...

  • Re: [4071] How to POP3 in C#

    Posted by burnt1ce85 on 12 Jun 2008

    Most pop3 mail servers encrypt their connection using SSL (port: 995). This tutorial seems to only cover accessing email using an unecrypted connection. Anyone knows a tutorial that covers encrypte...

  • Re: C#.net coding regards

    Posted by seamnia on 12 Nov 2007

    Hi VidyaRe: [4071] How to POP3 in C#

    Posted by thilagam on 20 Aug 2007

    Thanks for publishing this wonderfull article. I want to know how to save the attachment to the specified location automatically

  • mail.dll

    Posted by lesnikowski on 10 Nov 2005

    [url="http://www.lesnikowski.com/mail"]http://www.lesnikowski.com/mail[/url]