Troubleshooting: IMAP4
Common reason of e-mail account login problems or the messages not being accessible is one of the following:
- IMAP4 user name ( UserName property of IMAP4 object) is different from account name (or from e-mail address).
- Some IMAP4 servers expect user name in form of "account_name" while others - "account_name@domain.com". Sometimes, user name is not related with either account name or e-mail address. Contact your e-mail server administrator for details
- Mailbox not selected. Unlike POP3, IMAP4 supports multiple mailboxes (i.e. folders) per e-mail account. Once logged in e-mail account, user must select a mailbox (such as "Inbox") to be able to read or manage the messages
- Wrong or misspelled mailbox name. Also, in spite of "Inbox" and "INBOX" point to the same folder, "Outbox" and "OUTBOX" (or "sent" and "Sent") can be different folders. "Inbox" folder name is always case-insensitive but this is not necessary true for other folders
- IMAP4 protocol is not available on mail server. Many mail servers still do not support IMAP4 protocol (or it was disabled by server's administrator). Contact your mail server administrator for details
- IMAP4 server configuration (domains, MX records, etc.) is incorrect. Check your server's documentation for details
You can find out 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 AfterLogic Support Team to get prompt and helpful reply. It's all free!
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:\imap4_log.txt file. All possible errors are handled.
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
' 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
<%
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
' 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