Toolbox.NETMF.NET.POP3_Client


Toolbox.NETMF.NET.POP3_Client(Socket, Username, Password)
  • Socket A reference for the socket to be used (see also: SimpleSocket)
  • Username The username
  • Password The password

Methods

  • Connect() Connects to the mailserver.
  • Close() Closes the connection to the mailserver.
  • FetchBody(Id, IncludeHeaders) Returns the mail body of a specific mail.
  • FetchHeaders(uint Id) Returns the headers of a specific mail.
  • ListMails(Id, Size) Returns the Ids and sizes of each mail.

Properties

  • BoxSize Returns the size of the mailbox in bytes
  • MessageCount Returns the amount of messages on the server
  • IsConnected Returns wether we're connected to a mailserver or not

Sample code in C#

POP3_Client Mailbox = new POP3_Client(new IntegratedSocket("pop.yourisp.com", 110), "yourusername", "yourpassword");
Mailbox.Connect();
Debug.Print("Message count: " + Mailbox.MessageCount.ToString());
Debug.Print("Box size in bytes: " + Mailbox.BoxSize.ToString());

uint[] Id, Size;
Mailbox.ListMails(out Id, out Size);
for (int Index = 0; Index < Id.Length; ++Index)
{
    string[] Headers = Mailbox.FetchHeaders(Id[Index], new string[] { "subject", "from", "date" });
    Debug.Print("Mail ID " + Id[Index].ToString() + " is " + Size[Index].ToString() + " bytes");
    Debug.Print("Subject: " + Headers[0]);
    Debug.Print("From: " + Headers[1]);
    Debug.Print("Date: " + Headers[2]);
    Debug.Print("======================================================================");
}

Mailbox.Close();

Sample code in VB

Dim Mailbox As POP3_Client = New POP3_Client(new IntegratedSocket("pop.yourisp.com", 110), "yourusername", "yourpassword")
Mailbox.Connect()
Debug.Print("Message count: " + Mailbox.MessageCount.ToString())
Debug.Print("Box size in bytes: " + Mailbox.BoxSize.ToString())

Dim ReqHeaders(0 To 2) As String
ReqHeaders(0) = "subject"
ReqHeaders(1) = "from"
ReqHeaders(2) = "date"

Dim Id() As UInteger, Size() As UInteger
Mailbox.ListMails(Id, Size)
For Index As Integer = 0 To Id.Length - 1
    Dim Headers() As String = Mailbox.FetchHeaders(Id(Index), ReqHeaders)
    Debug.Print("Mail ID " + Id(Index).ToString() + " is " + Size(Index).ToString() + " bytes")
    Debug.Print("Subject: " + Headers(0))
    Debug.Print("From: " + Headers(1))
    Debug.Print("Date: " + Headers(2))
    Debug.Print("======================================================================")
Next

Mailbox.Close()

Last edited Jan 30, 2012 at 8:25 PM by Garrcomm, version 4