Skip to content
Andrew Lambert edited this page Jan 14, 2023 · 7 revisions

These examples demonstrate libcurl's basic support for listing, retrieving, and deleting emails on a POP3 server.

Retrieve an email

  Dim c As New cURLClient
  c.Username = "Bob"
  c.Password = "seekrit"
  If c.Get("pop3://pop.example.com/1") Then
    Dim email As String = c.GetDownloadedData
    MsgBox("Email retrieved successfully.")
  Else
    MsgBox("Error: " + Str(c.LastError))
  End If

Retrieve an email's headers only

  Dim c As New cURLClient
  c.Username = "Bob"
  c.Password = "seekrit"
  c.SetRequestMethod("TOP 1 0")
  If c.Get("pop3://pop.example.com") Then
    Dim emailheader As String = c.GetDownloadedData
    MsgBox("Email headers retrieved successfully.")
  Else
    MsgBox("Error: " + Str(c.LastError))
  End If

List emails in a mailbox

  Dim c As New cURLClient
  c.Username = "Bob"
  c.Password = "seekrit"
  If c.Get("pop3://pop.example.com/") Then
    MsgBox("Mailbox enumerated successfully.")
  Else
    MsgBox("Error: " + Str(c.LastError))
  End If

Delete an email from the server

  Dim c As New cURLClient
  c.Username = "Bob"
  c.Password = "seekrit"
  c.SetRequestMethod("DELE")
  If c.Head("pop3://pop.example.com/1") Then
    MsgBox("Message deleted successfully.")
  Else
    MsgBox("Error: " + Str(c.LastError))
  End If

POP3 NOOP (no-operation)

  Dim c As New cURLClient
  c.Username = "Bob"
  c.Password = "seekrit"
  c.SetRequestMethod("NOOP")
  If c.Head("pop3://pop.example.com/1") Then
    MsgBox("POP3 no-operation sent successfully.")
  Else
    MsgBox("Error: " + Str(c.LastError))
  End If
Clone this wiki locally