Selecting a mailbox
This sample connects to IMAP4 server, logs in e-mail account and selects "Inbox" folder for read/write access.
Note: "Mailbox" and "folder" terms mean the same.
SelectMailbox method used in this sample selects e-mail account folder for read/write access (i.e. you can both retrieve and manage e-mail).
ExamineMailbox method differs from SelectMailbox in that the folder is being selected for read-only access (i.e. you can only read e-mail).
Dim objIMAP4, objMsg
' Create IMAP4 object
Set objIMAP4 = CreateObject("MailBee.IMAP4")
' Enable logging IMAP4 session into a file
objIMAP4.EnableLogging = True
objIMAP4.LogFilePath = "C:\imap4_log.txt"
' Unlock IMAP4 object
objIMAP4.LicenseKey = "put your license key here"
' Set IMAP4 server name
objIMAP4.ServerName = "mail.server.com"
' Set user credentials
objIMAP4.UserName = "username"
objIMAP4.Password = "password"
' Connect to the server and
' log in email account
If objIMAP4.Connect Then
' Select Inbox folder
If objIMAP4.SelectMailbox("Inbox") Then
' All is fine
MsgBox "Inbox selected successfully"
Else
' Display error information
MsgBox "Error #" & objIMAP4.ErrCode
MsgBox "Server response: " & objIMAP4.ServerResponse
End If
' Close the connection
objIMAP4.Disconnect
Else
' Display error information
MsgBox "Error #" & objIMAP4.ErrCode
MsgBox "Server response: " & objIMAP4.ServerResponse
End If
<%
Dim objIMAP4, objMsg
' Create IMAP4 object
Set objIMAP4 = Server.CreateObject("MailBee.IMAP4")
' Enable logging IMAP4 session into a file
objIMAP4.EnableLogging = True
objIMAP4.LogFilePath = "C:\imap4_log.txt"
' Unlock IMAP4 object
objIMAP4.LicenseKey = "put your license key here"
' Set IMAP4 server name
objIMAP4.ServerName = "mail.server.com"
' Set user credentials
objIMAP4.UserName = "username"
objIMAP4.Password = "password"
' Connect to the server and
' log in email account
If objIMAP4.Connect Then
' Select Inbox folder
If objIMAP4.SelectMailbox("Inbox") Then
' All is fine
Response.Write "Inbox selected successfully"
Else
' Display error information
Response.Write "Error #" & objIMAP4.ErrCode & "<br>"
Response.Write "Server response: " & objIMAP4.ServerResponse
End If
' Close the connection
objIMAP4.Disconnect
Else
' Display error information
Response.Write "Error #" & objIMAP4.ErrCode & "<br>"
Response.Write "Server response: " & objIMAP4.ServerResponse
End If
%>
See Also:
ErrCode Property
ErrDesc Property
ServerResponse Property