Connect Method


Connects to the IMAP4 server and logs in the specified user account.

In order to call this method, make sure LicenseKey property is already set, otherwise, the method will fail.

Also, if you want to call this method without parameters, make sure to previously set the following properties:

If IMAP4 server operates on non-standard port (non-143), use PortNumber property to set appropriate value.

If you're using Integrated Windows Authentication (IWA), you may leave UserName and Password blank but must set AuthMethod property to use IWA-compatible authentication method.

Note: If Connect method is called with parameters, ServerName, PortNumber, UserName, Password, UserDomain, TargetName properties are automatcially updated to reflect specified parameters' values.


blnResult = ObjectName.Connect([ServerName], [PortNumber], [UserName], [Password], [UserDomain], [TargetName])  
Parameters:  
ServerName As String (optional) Server name to connect to. If not specified, current ServerName value will be used  
PortNumber As Long (optional) IMAP4 port number. If not specified, current PortNumber value will be used  
UserName As String (optional) The user account name. If not specified, current UserName value will be used  
Password As String (optional) The user account password. If not specified, current Password value will be used  
UserDomain As String (optional) The user domain name (only used with NTLM and Kerberos). If not specified, current UserDomain value will be used  
TargetName As String (optional) The SPN (only used with Kerberos). If not specified, current TargetName value will be used  
Return value As Boolean True if successful, False if connect procedure failed (mail server is not responding, username and/or password is incorrect, authentication method is not supported, license key is invalid). You can check ErrDesc property or log file to get more detailed error information  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.IMAP4")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.IMAP4")
'In ASP use Response.Write instead of MsgBox

Mailer.EnableLogging = True ' Logging helps to discover any problems
Mailer.LogFilePath = "C:\Temp\imap4_log.txt"

Mailer.LicenseKey = "put your license key here"
If Mailer.Connect("mailserver.com", 143, "MyName", "MyPassword") Then
  MsgBox "Connected successfully"
  Mailer.Disconnect
Else
  MsgBox Mailer.ErrDesc
End If

See Also:

ServerName Property
PortNumber Property
UserName Property
Password Property

ErrDesc Property

Disconnect Method


Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.