Skip to content
Dmitry Boyarintsev edited this page Nov 14, 2021 · 6 revisions

The front mail client classes to be used are ImapClient and Pop3Client classes. Both are descendants from TextClient, the class that's designed to support text-based network protocols.

  • Mail Client classes are disposable (since TextClient is IDisposable), and thus should be treated as such, either by applying using syntax, or calling Dispose() explicitly.
  • Internally the socket connection is retained until disposed.
  • Each methods is synchronous
  • Each class should be treated as thread-unsafe (as they're thread-unsafe)

Connecting

  • The connection information could be either passed as constructor parameter. (In which case the connection will be attempted at the time of constructor)
  • The connection can be initiated by calling Connect() method (declared at TextClient)

Message Parsing

The backbone of the emails (or rather internet messaging) is parsing of the mime-text. You might find the actual implementation of mime-structure parsing at MailMessage.cs ParseMime() method. Any received (Loaded) message is parsed into parts immediately and can be later be "Saved" and "Loaded" from some other storage.

Exceptions

Any method of ImapClient or Pop3Client can thrown an exception.

The most common cases are when the email server responses with an error to a request sent. Such responses would be thrown as Exception (or a specific ImapClientException. Pop3Client doesn't have a specific exception class).

Clone this wiki locally