SamLogic Internet Components - Home
SLPOP3 - Source Code Example

' This example source code shows how to use the SLPOP component to retrieve
' information about waiting e-mail messages on a POP3 server. The number of waiting
' e-mails and the total size of the e-mails are retrieved with this example.

' Opens a connection to a POP3 server
Private Sub GetPOP3Info_Click()
    sNrWaitingMails = ""
    sTotalSize = ""
    ' Specify POP3 server
    SLPOP1.MailServer = tPop3Server.Text
    ' Specify user name and password
    SLPOP1.Username = tUserName.Text
    SLPOP1.Password = tPassword.Text
    ' Open a connection to the POP3 server
    If SLPOP1.Connect Then
        sStatusInfo = "Reading information..."
        sStatusInfo = "Can not connect!"
    End If
End Sub

' Event - a connection is established
Private Sub SLPOP1_Connected()
    ' Retrieve number of waiting e-mails
    sNrWaitingMails = CStr(SLPOP1.GetNumWaitingMails())
    ' Retrieve the total size of the waiting e-mails (in bytes)
    sTotalSize = CStr(SLPOP1.GetSizeWaitingMails()) + " bytes"
    sStatusInfo = "The information have arrived from the POP3 server."
    ' Disconnect
End Sub

' Event - there was an error
Private Sub SLPOP1_ErrorOccured(ByVal ErrorCode As Long)
    sStatusInfo = "Error # " + CStr(ErrorCode) + " occurred!"
End Sub

' Event - the POP3 server reported an error
Private Sub SLPOP1_MailServerReportedError(ByVal Operation As Long)
    sStatusInfo = "The mail server reported an error!"
    If Operation = 1 Then sStatusInfo = "The user name is not correct!"
    If Operation = 2 Then sStatusInfo = "The password is not correct!"
End Sub

< Go back