• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Receive Mail

Receives mail messages from a POP3 server.

Code

using DRIT.Mail.Rfc.Pop3;

var options = new Pop3ClientOptions
{
    Host = "pop.example.com",
    Port = 995,
    SslMode = Pop3SslMode.Ssl,
    Credentials = new System.Net.NetworkCredential("user", "password"),
};

using var client = new Pop3Client(options);
client.Connect();
client.Authenticate();

Pop3MailboxStatus status = client.GetMailboxStatus();
Console.WriteLine($"Message count: {status.MessageCount}");
Console.WriteLine($"Total size:     {status.TotalSize}");

for (int i = 1; i <= status.MessageCount; i++)
{
    Pop3MessageInfo info = client.GetMessageInfo(i);
    Console.WriteLine($"{i}: {info.Size} bytes");

    byte[] raw = client.GetMessage(i);
    // Parse with MimeMessage.Load(new MemoryStream(raw)) if needed
}

client.Disconnect();

Remarks

Pop3Client implements RFC 1939. Message numbers are 1-based. Use GetMessageInfo to inspect message sizes before downloading full content.

  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX