POP3 Module
Overview
The Ferrysoft POP3 Module is a Post Office Protocol (POP3) client class to interrogate a POP3 server for available emails, download the emails and return them to the calling program. The POP3 Module is provided in source code form (Visual Basic 2008/2010 compatible and Visual C# 2008/2010 compatible). It is intended for developers, to incorporate into their own applications, in order to provide POP3 client support to the application. The module can be used, royalty-free, by any individual or organisation that purchases the module. As the module is provided in source code form, it can be modified as necessary after purchase, provided that any derived module is not distributed, in source code form, to a third party. The module can be incorporated into a commercial product and sold to third parties, in compiled format, provided that the purpose of the commercial product is not simply to act as a wrapper for the POP3 Module.
Buy It
The POP3 Module is available for download in a password protected zip file. A royalty-free source code licence to use the POP3 Module can be purchased. On completion of the purchase, Ferrysoft will email the password of the protected zip file to the purchaser to enable the POP3 Module to be extracted for use.
The POP3 Module is priced in Pounds Sterling (GBP), US Dollars (USD) and Euros (EUR).
| Ferrysoft POP3 Module | Price | PayPal | |
| Royalty-free source code licence (GBP) | £99 | ||
| Royalty-free source code licence (USD) | $199 | - | |
| Royalty-free source code licence (EUR) | €149 | - |
Summary
The Ferrysoft POP3 Module provides the capability to interrogate a POP3 server for available emails, download the emails and return them to the calling program.
Summary of methods provided by the class
The methods provided by the class are described in the following table.
| Method | Use |
| Close | Used to send the quit command to the server and then close the connection to the server. |
| DeleteMessage | Used to delete the specified message from the server. |
| GetCapabilityList | Used to retrieve the list of capabilities of the server. |
| GetMailboxStatus | Used to retrieve the mailbox statistics of MessageCount and MailboxSize. |
| GetMessage | Used to retrieve the specified message from the server. |
| GetMessageHeader | Used to retrieve the specified message header from the server. |
| GetMessageList | Used to retrieve the list of messages available for downloading from the server. |
| KeepAlive | Used to send the noop command to the server and so keep the session alive. |
| Open | Used to send the authentication details to the server and prepare the connection for subsequent communication with the server. |
| RollbackDeletes | Used to reset the session with the server so that any messages marked for deletion in this session are no longer marked for deletion. |
Summary of properties provided by the class
The properties provided by the class are described in the following table.
| Property | Use |
| AlternateViews | Get the collection of alternate views for the most recently retrieved message. A multipart message may contain text parts in alternate formats (for example text/plain or text/html). If the message is not multipart then the message text is contained in the first and only alternate view. Each text part is contained in an alternate view class. Each alternate view class contains Content, ContentDescription, ContentId, ContentTransferEncoding (Mechanism) and ContentType (MediaType, CharSet and Name). |
| AttachmentParts | Get the collection of attachment parts for the most recently retrieved message. Each attachment part is contained in an attachment part class. Each attachment part class contains Content, ContentDescription, ContentDisposition (DispositionType, FileName, Size, CreationDate, ModificationDate and ReadDate), ContentId, ContentSize, ContentTransferEncoding (Mechanism) and ContentType (MediaType, CharSet and Name). |
| CapabilityList | Get the collection of capability list items from the most recent use of the GetCapabilityList method. Each capability list item is contained in a capability list item class. Each capability list item class contains Tag and Parameters. |
| InlineParts | Get the collection of inline parts for the most recently retrieved message. Each inline part is contained in an inline part class. Each inline part class contains Content, ContentDescription, ContentId, ContentSize, ContentTransferEncoding (Mechanism) and ContentType (MediaType, CharSet and Name). |
| LastCommandSent | Get the last command sent to the server. |
| LastResponseOK | Get a true/false indicator of whether the last response from the server was an OK response. |
| LastResponseReceived | Get the last response received from the server. |
| MailboxSize | Get the size (number of octets) for the most recently opened mailbox. |
| MessageCount | Get the number of messages for the most recently opened mailbox. |
| MessageHeader | Get the message header class for the most recently retrieved message. The message header class contains Bcc, Cc, ContentDescription, ContentDisposition, ContentDispositionCreationDate, ContentDispositionDispositionType, ContentDispositionFileName, ContentDispositionModificationDate, ContentDispositionReadDate, ContentDispositionSize, ContentId, ContentTransferEncoding, ContentType, ContentTypeBoundary, ContentTypeCharSet, ContentTypeMediaType, ContentTypeName, Date, From, FromEmailAddress, InReplyTo, MessageId, MimeVersion, References, ReplyTo, Sender, Subject, and To. |
| MessageHeaders | Get the collection of message headers for the most recently retrieved message. |
| MessageList | Get the collection of message list items from the most recent use of the GetMessageList method. Each message list item is contained in a message list item class. Each message list item class contains Number, Id and Size. |
| MessageSize | Get the size (number of octets) for the most recently retrieved message. |
| State | Get the connection state. |
Close method
Syntax
Visual Basic
Public Sub Close()
C#
public void Close()
DeleteMessage method
Syntax
Visual Basic
Public Sub DeleteMessage( _ ByVal MessageNumber As Integer)
C#
public void DeleteMessage( int MessageNumber)
Parameters
- MessageNumber
- The message number (1-n) of the message to delete from the server.
GetCapabilityList method
Syntax
Visual Basic
Public Sub GetCapabilityList()
C#
public void GetCapabilityList()
GetMailboxStatus method
Syntax
Visual Basic
Public Sub GetMailboxStatus()
C#
public void GetMailboxStatus()
GetMessage method
Syntax
Visual Basic
Public Sub GetMessage( _ ByVal MessageNumber As Integer)
C#
public void GetMessage( int MessageNumber)
Parameters
- MessageNumber
- The message number (1-n) of the message to retrieve from the server.
GetMessageHeader method
Syntax
Visual Basic
Public Sub GetMessageHeader( _ ByVal MessageNumber As Integer)
C#
public void GetMessageHeader( int MessageNumber)
Parameters
- MessageNumber
- The message number (1-n) of the message header to retrieve from the server.
GetMessageList method
Syntax
Visual Basic
Public Sub GetMessageList()
C#
public void GetMessageList()
KeepAlive method
Syntax
Visual Basic
Public Sub KeepAlive()
C#
public void KeepAlive()
Open method
Syntax
Visual Basic
Public Sub Open( _ ByVal Pop3Server As String, _ ByVal Pop3Port As Integer, _ ByVal Pop3Encrypted As Boolean, _ ByVal Pop3Username As String, _ ByVal Pop3Password As String)
C#
public void Open( string Pop3Server, int Pop3Port, bool Pop3Encrypted, string Pop3Username, string Pop3Password)
Parameters
- Pop3Server
- The server name of the POP3 Server. For example, the fictitious server "pop3.example.com".
- Pop3Port
- The server port number. For an unencrypted connection, the server port number should typically be set to 110. For an encrypted connection, the server port number should typically be set to 995.
- Pop3Encrypted
- Indicates whether the server requires an encrypted connection.
The parameter can be either of the following:
- True - Requires an encrypted connection
- False - Does not require an encrypted connection
- Pop3Username
- The username to connect to the server.
- Pop3Password
- The password to connect to the server.
RollbackDeletes method
Syntax
Visual Basic
Public Sub RollbackDeletes()
C#
public void RollbackDeletes()
AlternateViews property
Syntax
Visual Basic
Public ReadOnly Property AlternateViews As System.Collections.ArrayList
C#
public System.Collections.ArrayList AlternateViews { get; }
Using the AlternateViews property
Get the collection of alternate views for the most recently retrieved message. A multipart message may contain text parts in alternate formats (for example text/plain or text/html). If the message is not multipart then the message text is contained in the first and only alternate view. Each text part is contained in an alternate view class. Each alternate view class contains Content, ContentDescription, ContentId, ContentTransferEncoding (Mechanism) and ContentType (MediaType, CharSet and Name).
AttachmentParts property
Syntax
Visual Basic
Public ReadOnly Property AttachmentParts As System.Collections.ArrayList
C#
public System.Collections.ArrayList AttachmentParts { get; }
Using the AttachmentParts property
Get the collection of attachment parts for the most recently retrieved message. Each attachment part is contained in an attachment part class. Each attachment part class contains Content, ContentDescription, ContentDisposition (DispositionType, FileName, Size, CreationDate, ModificationDate and ReadDate), ContentId, ContentSize, ContentTransferEncoding (Mechanism) and ContentType (MediaType, CharSet and Name).
CapabilityList property
Syntax
Visual Basic
Public ReadOnly Property CapabilityList As System.Collections.ArrayList
C#
public System.Collections.ArrayList CapabilityList { get; }
Using the CapabilityList property
Get the collection of capability list items from the most recent use of the GetCapabilityList method. Each capability list item is contained in a capability list item class. Each capability list item class contains Tag and Parameters.
InlineParts property
Syntax
Visual Basic
Public ReadOnly Property InlineParts As System.Collections.ArrayList
C#
public System.Collections.ArrayList InlineParts { get; }
Using the InlineParts property
Get the collection of inline parts for the most recently retrieved message. Each inline part is contained in an inline part class. Each inline part class contains Content, ContentDescription, ContentId, ContentSize, ContentTransferEncoding (Mechanism) and ContentType (MediaType, CharSet and Name).
LastCommandSent property
Syntax
Visual Basic
Public ReadOnly Property LastCommandSent As String
C#
public string LastCommandSent { get; }
Using the LastCommandSent property
Get the last command sent to the server.
LastResponseOK property
Syntax
Visual Basic
Public ReadOnly Property LastResponseOK As Boolean
C#
public bool LastResponseOK { get; }
Using the LastResponseOK property
Get a true/false indicator of whether the last response from the server was an OK response.
LastResponseReceived property
Syntax
Visual Basic
Public ReadOnly Property LastResponseReceived As String
C#
public string LastResponseReceived { get; }
Using the LastResponseReceived property
Get the last response received from the server.
MailboxSize property
Syntax
Visual Basic
Public ReadOnly Property MailboxSize As Long
C#
public long MailboxSize { get; }
Using the MailboxSize property
Get the size (number of octets) for the most recently opened mailbox.
MessageCount property
Syntax
Visual Basic
Public ReadOnly Property MessageCount As Integer
C#
public int MessageCount { get; }
Using the MessageCount property
Get the number of messages for the most recently opened mailbox.
MessageHeader property
Syntax
Visual Basic
Public ReadOnly Property MessageHeader As Ferrysoft.Pop3.MessageHeader
C#
public Ferrysoft.Pop3.MessageHeader MessageHeader { get; }
Using the MessageHeader property
Get the message header class for the most recently retrieved message. The message header class contains Bcc, Cc, ContentDescription, ContentDisposition, ContentDispositionCreationDate, ContentDispositionDispositionType, ContentDispositionFileName, ContentDispositionModificationDate, ContentDispositionReadDate, ContentDispositionSize, ContentId, ContentTransferEncoding, ContentType, ContentTypeBoundary, ContentTypeCharSet, ContentTypeMediaType, ContentTypeName, Date, From, FromEmailAddress, InReplyTo, MessageId, MimeVersion, References, ReplyTo, Sender, Subject, and To.
MessageHeaders property
Syntax
Visual Basic
Public ReadOnly Property MessageHeaders _ As System.Collections.Generic.Dictionary(Of Integer, String)
C#
public System.Collections.Generic.Dictionary<int, string> MessageHeaders { get; }
Using the MessageHeaders property
- Get the collection of message headers for the most recently retrieved message. The collection can be accessed sequentially or selectively using any of the following enumerations of Ferrysoft.Pop3.MessageHeaderType:
- Bcc
- Cc
- ContentDescription
- ContentDisposition
- ContentDispositionCreationDate
- ContentDispositionDispositionType
- ContentDispositionFileName
- ContentDispositionModificationDate
- ContentDispositionReadDate
- ContentDispositionSize
- ContentID
- ContentTransferEncoding
- ContentType
- ContentTypeBoundary
- ContentTypeCharSet
- ContentTypeMediaType
- ContentTypeName
- Date
- From
- FromEmailAddress
- InReplyTo
- MessageID
- MIMEVersion
- References
- ReplyTo
- Sender
- Subject
- To
MessageList property
Syntax
Visual Basic
Public ReadOnly Property MessageList As System.Collections.ArrayList
C#
public System.Collections.ArrayList MessageList { get; }
Using the MessageList property
Get the collection of message list items from the most recent use of the GetMessageList method. Each message list item is contained in a message list item class. Each message list item class contains Number, Id and Size.
MessageSize property
Syntax
Visual Basic
Public ReadOnly Property MessageSize As Integer
C#
public int MessageSize { get; }
Using the MessageSize property
Get the size (number of octets) for the most recently retrieved message.
State property
Syntax
Visual Basic
Public ReadOnly Property State As Ferrysoft.Pop3.ConnectionState
C#
public Ferrysoft.Pop3.ConnectionState State { get; }
Using the State property
- Get the connection state. The connection state can be returned as any of the following enumerations of Ferrysoft.Pop3.ConnectionState:
- Closed
- Open
Example Use
The code below shows an example of how to use the POP3 client class.
Visual Basic
' ' This example uses the POP3 object to connect ' to a POP3 server and process any messages ' waiting in the mailbox. For each message, ' the message headers, alternate views and ' attachments are shown. ' Dim Pop3Client As Ferrysoft.Pop3.Client Dim Pop3Server As String Dim Pop3Port As Integer Dim Pop3Encrypted As Boolean Dim Pop3Username As String Dim Pop3Password As String Dim MailboxSize As Long = 0 Dim MessageCount As Integer = 0 Dim MessageSize As Integer = 0 Pop3Client = New Ferrysoft.Pop3.Client() ' ' Set the Server, Username, Password ' and Encrypted to the credentials needed ' in order to connect to your POP3 mailbox. ' Port is defaulted according to the ' setting of Encrypted. ' Port can be overridden if a non-standard ' port is required to access your POP3 mailbox. ' Pop3Server = "pop.example.com" Pop3Username = "myusername" Pop3Password = "mypassword" Pop3Encrypted = True If Pop3Encrypted Then Pop3Port = 995 Else Pop3Port = 110 End If Try WriteLineString("Init started") Pop3Client.Open( _ Pop3Server, _ Pop3Port, _ Pop3Encrypted, _ Pop3Username, _ Pop3Password) If Pop3Client.LastResponseOK Then WriteLineSent(Pop3Client) WriteLineReceived(Pop3Client) MessageCount = Pop3Client.MessageCount MailboxSize = Pop3Client.MailboxSize WriteLineValue("Message Count", MessageCount) WriteLineValue("Mailbox Size", MailboxSize) Else WriteLineString("Open failed") WriteLineSent(Pop3Client) WriteLineReceived(Pop3Client) End If WriteLineString("Init finished") Catch WriteLineString("EXCEPTION") End Try If MessageCount <> 0 Then Try For MessageNumber = 1 To MessageCount Pop3Client.GetMessage(MessageNumber) If Pop3Client.LastResponseOK Then WriteLineSent(Pop3Client) WriteLineOK(Pop3Client) MessageSize = Pop3Client.MessageSize WriteLineValue("Message Size", MessageSize) WriteLineMessageHeaders(Pop3Client) WriteLineAlternateViews(Pop3Client) WriteLineInlineParts(Pop3Client) WriteLineAttachmentParts(Pop3Client) Else WriteLineString("GetMessage failed") WriteLineSent(Pop3Client) WriteLineReceived(Pop3Client) End If Next Catch WriteLineString("EXCEPTION") End Try End If Try WriteLineString("Term started") If Pop3Client.State <> Ferrysoft.Pop3.ConnectionState.Closed Then Pop3Client.Close() WriteLineSent(Pop3Client) WriteLineReceived(Pop3Client) End If WriteLineString("Term finished") Catch WriteLineString("EXCEPTION") End Try Private Sub WriteLineMessageHeaders( _ ByVal Pop3Client As Ferrysoft.Pop3.Client) ' ' Show the message headers. ' WriteLineString("Message Headers ...") System.Console.WriteLine("{0}: {1}", "Subject", _ Pop3Client.MessageHeader.Subject) System.Console.WriteLine("{0}: {1}", "From", _ Pop3Client.MessageHeader.From) System.Console.WriteLine("{0}: {1}", "To", _ Pop3Client.MessageHeader.To) WriteLineString("End Message Headers") End Sub Private Sub WriteLineAlternateViews( _ ByVal Pop3Client As Ferrysoft.Pop3.Client) ' ' Show the alternate views. ' WriteLineString("Alternate Views ...") For Each AlternateView As Ferrysoft.Pop3.AlternateView _ In Pop3Client.AlternateViews WriteLineAlternateView(AlternateView) Next WriteLineString("End Alternate Views") End Sub Private Sub WriteLineInlineParts( _ ByVal Pop3Client As Ferrysoft.Pop3.Client) ' ' Show the inline parts. ' WriteLineString("Inline Parts ...") For Each InlinePart As Ferrysoft.Pop3.InlinePart _ In Pop3Client.InlineParts WriteLineInlinePart(InlinePart) Next WriteLineString("End Inline Parts") End Sub Private Sub WriteLineAttachmentParts( _ ByVal Pop3Client As Ferrysoft.Pop3.Client) ' ' Show the attachment parts. ' WriteLineString("Attachment Parts ...") For Each AttachmentPart As Ferrysoft.Pop3.AttachmentPart _ In Pop3Client.AttachmentParts WriteLineAttachmentPart(AttachmentPart) Next WriteLineString("End Attachment Parts") End Sub Private Sub WriteLineAlternateView( _ ByVal AlternateView As Ferrysoft.Pop3.AlternateView) ' ' Show the alternate view. ' WriteLineString("Alternate View ...") WriteLineString(AlternateView.ContentType.ToString()) WriteLineString(AlternateView.ContentTransferEncoding.ToString()) WriteLineString(AlternateView.Content) WriteLineString("End Alternate View") End Sub Private Sub WriteLineInlinePart( _ ByVal InlinePart As Ferrysoft.Pop3.InlinePart) ' ' Show the inline part. ' WriteLineString("Inline Part ...") WriteLineString(InlinePart.ContentType.ToString()) WriteLineString(InlinePart.ContentTransferEncoding.ToString()) WriteLineString(InlinePart.ContentId.ToString()) WriteLineString("End Inline Part") End Sub Private Sub WriteLineAttachmentPart( _ ByVal AttachmentPart As Ferrysoft.Pop3.AttachmentPart) ' ' Show the attachment part. ' WriteLineString("Attachment Part ...") WriteLineString(AttachmentPart.ContentType.ToString()) WriteLineString(AttachmentPart.ContentTransferEncoding.ToString()) WriteLineString(AttachmentPart.ContentDisposition.ToString()) WriteLineString("End Attachment Part") End Sub Private Sub WriteLineSent( _ ByVal Pop3Client As Ferrysoft.Pop3.Client) ' ' Show the last command sent from the client to the server. ' System.Console.WriteLine("Client: {0}", Pop3Client.LastCommandSent) End Sub Private Sub WriteLineReceived( _ ByVal Pop3Client As Ferrysoft.Pop3.Client) ' ' Show the last response received from the server by the client. ' System.Console.WriteLine("Server: {0}", Pop3Client.LastResponseReceived) End Sub Private Sub WriteLineOK( _ ByVal Pop3Client As Ferrysoft.Pop3.Client) ' ' Show the OK or ERR response received from the server by the client. ' If Pop3Client.LastResponseOK Then WriteLineString("Server: +OK") Else WriteLineString("Server: -ERR") End If End Sub Private Sub WriteLineValue( _ ByVal NameString As String, _ ByVal ValueLong As Long) ' ' Show a name value pair. ' System.Console.WriteLine("{0}: {1:0}", NameString, ValueLong) End Sub Private Sub WriteLineString( _ ByVal ValueString As String) ' ' Show a string. ' System.Console.WriteLine(ValueString) End Sub
C#
// // This example uses the POP3 object to connect // to a POP3 server and process any messages // waiting in the mailbox. For each message, // the message headers, alternate views and // attachments are shown. // Ferrysoft.Pop3.Client Pop3Client; string Pop3Server; int Pop3Port; bool Pop3Encrypted; string Pop3Username; string Pop3Password; long MailboxSize = 0; int MessageCount = 0; int MessageSize = 0; Pop3Client = new Ferrysoft.Pop3.Client(); // // Set the Server, Username, Password // and Encrypted to the credentials needed // in order to connect to your POP3 mailbox. // Port is defaulted according to the // setting of Encrypted. // Port can be overridden if a non-standard // port is required to access your POP3 mailbox. // Pop3Server = "pop.example.com"; Pop3Username = "myusername"; Pop3Password = "mypassword"; Pop3Encrypted = true; if (Pop3Encrypted) Pop3Port = 995; else Pop3Port = 110; try { WriteLineString("Init started"); Pop3Client.Open( Pop3Server, Pop3Port, Pop3Encrypted, Pop3Username, Pop3Password); if (Pop3Client.LastResponseOK) { WriteLineSent(Pop3Client); WriteLineReceived(Pop3Client); MessageCount = Pop3Client.MessageCount; MailboxSize = Pop3Client.MailboxSize; WriteLineValue("Message Count", MessageCount); WriteLineValue("Mailbox Size", MailboxSize); } else { WriteLineString("Open failed"); WriteLineSent(Pop3Client); WriteLineReceived(Pop3Client); } WriteLineString("Init finished"); } catch { WriteLineString("EXCEPTION"); } if (MessageCount != 0) { try { for (int MessageNumber = 1; MessageNumber <= MessageCount; MessageNumber++) { Pop3Client.GetMessage(MessageNumber); if (Pop3Client.LastResponseOK) { WriteLineSent(Pop3Client); WriteLineOK(Pop3Client); MessageSize = Pop3Client.MessageSize; WriteLineValue("Message Size", MessageSize); WriteLineMessageHeaders(Pop3Client); WriteLineAlternateViews(Pop3Client); WriteLineInlineParts(Pop3Client); WriteLineAttachmentParts(Pop3Client); } else { WriteLineString("GetMessage failed"); WriteLineSent(Pop3Client); WriteLineReceived(Pop3Client); } } } catch { WriteLineString("EXCEPTION"); } } try { WriteLineString("Term started"); if (Pop3Client.State != Ferrysoft.Pop3.ConnectionState.Closed) { Pop3Client.Close(); WriteLineSent(Pop3Client); WriteLineReceived(Pop3Client); } WriteLineString("Term finished"); } catch { WriteLineString("EXCEPTION"); } private static void WriteLineMessageHeaders( Ferrysoft.Pop3.Client Pop3Client) { // // Show the message headers. // WriteLineString("Message Headers ..."); System.Console.WriteLine("{0}: {1}", "Subject", Pop3Client.MessageHeader.Subject); System.Console.WriteLine("{0}: {1}", "From", Pop3Client.MessageHeader.From); System.Console.WriteLine("{0}: {1}", "To", Pop3Client.MessageHeader.To); WriteLineString("End Message Headers"); } private static void WriteLineAlternateViews( Ferrysoft.Pop3.Client Pop3Client) { // // Show the alternate views. // WriteLineString("Alternate Views ..."); foreach (Ferrysoft.Pop3.AlternateView AlternateView in Pop3Client.AlternateViews) { WriteLineAlternateView(AlternateView); } WriteLineString("End Alternate Views"); } private static void WriteLineInlineParts( Ferrysoft.Pop3.Client Pop3Client) { // // Show the inline parts. // WriteLineString("Inline Parts ..."); foreach (Ferrysoft.Pop3.InlinePart InlinePart in Pop3Client.InlineParts) { WriteLineInlinePart(InlinePart); } WriteLineString("End Inline Parts"); } private static void WriteLineAttachmentParts( Ferrysoft.Pop3.Client Pop3Client) { // // Show the attachment parts. // WriteLineString("Attachment Parts ..."); foreach (Ferrysoft.Pop3.AttachmentPart AttachmentPart in Pop3Client.AttachmentParts) { WriteLineAttachmentPart(AttachmentPart); } WriteLineString("End Attachment Parts"); } private static void WriteLineAlternateView( Ferrysoft.Pop3.AlternateView AlternateView) { // // Show the alternate view. // WriteLineString("Alternate View ..."); WriteLineString(AlternateView.ContentType.ToString()); WriteLineString(AlternateView.ContentTransferEncoding.ToString()); WriteLineString(AlternateView.Content); WriteLineString("End Alternate View"); } private static void WriteLineInlinePart( Ferrysoft.Pop3.InlinePart InlinePart) { // // Show the inline part. // WriteLineString("Inline Part ..."); WriteLineString(InlinePart.ContentType.ToString()); WriteLineString(InlinePart.ContentTransferEncoding.ToString()); WriteLineString(InlinePart.ContentId.ToString()); WriteLineString("End Inline Part"); } private static void WriteLineAttachmentPart( Ferrysoft.Pop3.AttachmentPart AttachmentPart) { // // Show the attachment part. // WriteLineString("Attachment Part ..."); WriteLineString(AttachmentPart.ContentType.ToString()); WriteLineString(AttachmentPart.ContentTransferEncoding.ToString()); WriteLineString(AttachmentPart.ContentDisposition.ToString()); WriteLineString("End Attachment Part"); } private static void WriteLineSent( Ferrysoft.Pop3.Client Pop3Client) { // // Show the last command sent from the client to the server. // System.Console.WriteLine("Client: {0}", Pop3Client.LastCommandSent); } private static void WriteLineReceived( Ferrysoft.Pop3.Client Pop3Client) { // // Show the last response received from the server by the client. // System.Console.WriteLine("Server: {0}", Pop3Client.LastResponseReceived); } private static void WriteLineOK( Ferrysoft.Pop3.Client Pop3Client) { // // Show the OK or ERR response received from the server by the client. // if (Pop3Client.LastResponseOK) WriteLineString("Server: +OK"); else WriteLineString("Server: -ERR"); } private static void WriteLineValue( string NameString, long ValueLong) { // // Show a name value pair. // System.Console.WriteLine("{0}: {1:0}", NameString, ValueLong); } private static void WriteLineString( string ValueString) { // // Show a string. // System.Console.WriteLine(ValueString); }
In the example below, the above code is run against a POP3 server with two messages waiting in the user's mailbox. It produces the following output:
Init started Client: STAT Server: +OK 2 4852 Message Count: 2 Mailbox Size: 4852 Init finished Client: RETR 1 Server: +OK Message Size: 2421 Message Headers ... Subject: Test Message A From: "John Doe" <john.doe@example.com> To: <jane.doe@example.com> End Message Headers Alternate Views ... Alternate View ... Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This is test message A. It is a single-part plain text message. End Alternate View End Alternate Views Inline Parts ... End Inline Parts Attachment Parts ... End Attachment Parts Client: RETR 2 Server: +OK Message Size: 2431 Message Headers ... Subject: Test Message B From: "John Doe" <john.doe@example.com> To: <jane.doe@example.com> End Message Headers Alternate Views ... Alternate View ... Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This is test message B. It is a single-part plain text message. End Alternate View End Alternate Views Inline Parts ... End Inline Parts Attachment Parts ... End Attachment Parts Term started Client: QUIT Server: +OK Farewell. Term finished