Learning the number of messages (MailBee Objects Tutorials)

From AfterLogic Wiki

Jump to: navigation, search

The sample prints the number of messages in the mailbox.

MessageCount is a key property of this sample.

Dim objPOP3
 
' Create POP3 object
Set objPOP3 = CreateObject("MailBee.POP3")
 
' Unlock POP3 object
objPOP3.LicenseKey = "put your license key here"
 
' Set POP3 server name
objPOP3.ServerName = "mail.server.com"
 
' Force APOP authentication
objPOP3.AuthMethod = 1
 
' Set user credentials
objPOP3.UserName = "username"
objPOP3.Password = "password"
 
' Connect to the server and log in the mailbox
If objPOP3.Connect Then
 
  ' Display the number of messages
  MsgBox objPOP3.MessageCount & " messages"
 
  ' Close the connection
  objPOP3.Disconnect
Else
  ' Display error information
  MsgBox "Error #" & objPOP3.ErrCode
  MsgBox "Server response: " & objPOP3.ServerResponse
End If
<%
Dim objPOP3
 
' Create POP3 object
Set objPOP3 = Server.CreateObject("MailBee.POP3")
 
' Unlock POP3 object
objPOP3.LicenseKey = "put your license key here"
 
' Set POP3 server name
objPOP3.ServerName = "mail.server.com"
 
' Force APOP authentication
objPOP3.AuthMethod = 1
 
' Set user credentials
objPOP3.UserName = "username"
objPOP3.Password = "password"
 
' Connect to the server and log in the mailbox
If objPOP3.Connect Then
 
  ' Display the number of messages
  Response.Write objPOP3.MessageCount & " messages"
 
  ' Close the connection
  objPOP3.Disconnect
Else
  ' Display error information
  Response.Write "Error #" & objPOP3.ErrCode & "<br>"
  Response.Write "Server response: " & objPOP3.ServerResponse
End If
%>

See Also:
MessageCount Property