This article illustrates how to get mailbox information such as the number of messages, the size of mailbox and the unique id of a specific message using Spire.Email component.
Detail steps:
Step 1: Create a pop3 client.
Pop3Client pop = new Pop3Client();
Step 2: Set host, authentication, port and connection protocol.
pop.Host = "outlook.office365.com"; pop.Username = "LeonDavisLD@outlook.com"; pop.Password = "password"; pop.Port = 995; pop.EnableSsl = true;
Step 3: Connect the pop server.
pop.Connect();
Step 4: Get information of mailbox.
//Get the number of messages Console.WriteLine("Mailbox message count: " + pop.GetMessageCount()); //Get the size of mailbox Console.WriteLine("Mailbox size: " + pop.GetSize() + " bytes"); //Get the unique id of the first message Console.WriteLine("Message uid: " + pop.GetMessagesUid(1));
Screenshot:
Full code:
[C#]
using System; using Spire.Email.Pop3; namespace Get_mailbox_information { class Program { static void Main(string[] args) { //Create a pop3 client using (Pop3Client pop = new Pop3Client()) { //Set host, authentication, port and connection protocol pop.Host = "outlook.office365.com"; pop.Username = "LeonDavisLD@outlook.com"; pop.Password = "password"; pop.Port = 995; pop.EnableSsl = true; //Connect the pop server pop.Connect(); //Get the number of messages Console.WriteLine("Mailbox message count: " + pop.GetMessageCount()); //Get the size of mailbox Console.WriteLine("Mailbox size: " + pop.GetSize() + " bytes"); //Get the unique id of the first message Console.WriteLine("Message uid: " + pop.GetMessagesUid(1)); } } } }
[VB.NET]
Imports Spire.Email.Pop3 Namespace Get_mailbox_information Class Program Private Shared Sub Main(args As String()) 'Create a pop3 client Using pop As New Pop3Client() 'Set host, authentication, port and connection protocol pop.Host = "outlook.office365.com" pop.Username = "LeonDavisLD@outlook.com" pop.Password = "password" pop.Port = 995 pop.EnableSsl = True 'Connect the pop server pop.Connect() 'Get the number of messages Console.WriteLine("Mailbox message count: " + pop.GetMessageCount()) 'Get the size of mailbox Console.WriteLine("Mailbox size: " + pop.GetSize() + " bytes") 'Get the unique id of the first message Console.WriteLine("Message uid: " + pop.GetMessagesUid(1)) End Using End Sub End Class End Namespace