Troubleshooting

Visual Basic Code | ASP Code

Common reason of e-mail account login problems or the messages not being accessible is one of the following: You can exact reason of the problem from MailBee's log file. To enable logging, set EnableLogging and LogFilePath properties of IMAP4 object.

If the problem persists, don't hesitate to contact our Technical Support Team to get a prompt and helpful reply.

This sample connects to the IMAP4 server, selects "Inbox" folder, and then completely retrieves first message in the folder. IMAP4 session log is written into "C:\Temp\imap4_log.txt" file. All possible errors are handled.

[Visual Basic]:

Dim objIMAP4, objMsg

' Create IMAP4 object
Set objIMAP4 = CreateObject("MailBee.IMAP4")

' Enable logging IMAP4 session into a file
objIMAP4.EnableLogging = True
objIMAP4.LogFilePath = "C:\Temp\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
  
    ' Completely retrieve first message
    Set objMsg = objIMAP4.RetrieveSingleMessage(1)

    If Not objIMAP4.IsError Then
      ' Display the number of
      ' attachments in the message
      MsgBox "The message contains " & _
        objMsg.Attachments.Count & " attachment(s)"
    Else
      ' Display error information
      MsgBox "Error #" & objIMAP4.ErrCode & ", " & objIMAP4.ErrDesc
    End If
  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

[ASP]:

<%
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:\Temp\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
  
    ' Completely retrieve first message
    Set objMsg = objIMAP4.RetrieveSingleMessage(1, False)

    If Not objIMAP4.IsError Then
      ' Display the number of
      ' attachments in the message
      Response.Write "The message contains " & _
        objMsg.Attachments.Count & " attachment(s)"
    Else
      ' Display error information
      Response.Write "Error #" & objIMAP4.ErrCode & ", " & objIMAP4.ErrDesc
    End If
  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

 


Send feedback to AfterLogic
Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.