Introduction

Everyone who has a computer or mobile device has used mail. The mail system
is an old, traditional simple protocol.
The purpose of this article (part2) is to explore the insides of the POP3 protocol and show you how to implement it with C#.

Password security

POP3 authentication is low-security since the username and password are send
as raw text into the network. Malicious software or people can sniff your password and use it maliciously.
A-POP is different from POP3 since the sent password is encoded by MD5Digest with
the challenge text received from the server. The server compares the saved challenge text and text received from
the client.
There is no way to receive the actual password text. So A-POP is secure than POP authentication.

Get mail list

After authentication, you can get the mail list using the LIST command. The response text of
the LIST command is as below.

To show HTML to your UI component, you must set this htmlText to your control. In
a Windows Forms or WPF application, use the browser control to show it.
In a web application, you can select some control, HtmlGenericControl,
Label control, ...etc. Here is some sample code for a web application:

Delete mail

Here is the delete process in POP3:

You can see that the response text of the DELE command is like below.

+OK marked for deletion

The Dele command marks the mail that you indicate as candidate for deletion. These marked mails will be deleted when you send
the quit command.
You can delete a mail by using the DeleteMail method of the Pop3Client object.

There is no authenticate required since all processes (open connection, authenticate, dele, quit) will automatically execute inside
the DeleteMail method.
Here is an implementation of the DeleteMail method:

The characters you can use in message body is 7bit char only. If you want to send "ありがとうございます" (it is a
Japanese character that means thank you),
you must encode it using Quoted-Printable or Base64 encoding. The mail format has
been very complex since its history.

Important RCFs are 822, 2045-2049, 2231, 2282, 2407. Please check more details if you want to know.

Manage read or unread with the UIDL command

POP3 does not have functionality to manage read state. You must use your own implementation to manage read or not.
You can use the UIDL command to achieve read state management. Here is the response text of
a UIDL command:

I save the email text and the content of the attachment in one file, with these instructions
but I need the attachment only with its name for example "order.txt". (Not the email text)
The instruciotn ct.FileName returns always "winmail.dat"

>I have added all of the Higlabo libraries that I can think of.
You think all but it is not.
As you say yourself not proficient, I guess that there is a lack sufficient technical capacity.
Why I guess so, you copied my code of Pop3Client class to HomeController.
But red squiggly underlined show some required method or parameter that you are missing.
And your code does not implement IDisposable at HomeController class.
That cause problem because Pop3Client implement IDisposable due to handle socket object correctly.

So, I recommend reuse my library by adding reference to dll, because it is more easy than copy libary.It is free copy or reference dll, but I recomment add reference to dll.

Please tell me what do you want to do by using my library?
I can't tell you how to integrate my library to your controller because I don't know the detail of your library.
But I can tell you how to use my library to suite your requirement.

Thank you for your patience, understanding and willingness to help a less than knowledgeable programmer trying to learn how to use classes and c# programming.

At the beginning of this Part 2 article, you say "At first, you must authenticate the mailbox with your username and password." and then you show the AuthenticateByPop() method. I understood that to mean that I should use your code to open a connection.

>> Please tell me what do you want to do by using my library? <<
I am simply trying to use your library to read emails from my mail server and display them in a grid.

I have successfully done that without actually opening a connection, which is another area I am confused about. If you say "Here is the basic flow to receive mail:
•Open connection
•Authenticate
•List
•Retr
•Quit"

My code does not perform any opening of a connection. Yet, the code does what I am expecting.

Thanks for your time and effort in trying to help me. I don't know very much, so I will continue to study and try to catch up on how your library should be used.

Hello,
After reading your project I was so happy to know that someone could help me with mine (Receiving response from POP3 mail server[^]), please take a look at mine then tell me :
- Is it possible in Visual Basic to retrieve the Message Title and the HTML structure ?