Connect Method


Connects to the SMTP server.

Make sure to set the following properties before calling this method:

It's not required to call this method in order to connect to SMTP server (though it's recommended). Methods of SMTP object (such as Send, SendEx, RelayMessage) automatically call it if the connection is not established.

If you want to use ESMTP authentication (EHLO command), also set AuthMethod and UserName/Password properties before calling Connect method.

Note: If ESMTP authentication is not used (AuthMethod=0), connection procedure starts with "HELO Your domain" command. You can specify "Your domain" explicitly using Domain property. If Domain property is empty, domain part of SMTP.Message.FromAddr property will be used. If SMTP.Message.FromAddr is also empty to the moment of calling Connect method, host name of the machine running MailBee will be used as a domain.


blnResult = ObjectName.Connect  
Parameters: None 
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 may 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.SMTP")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.SMTP")
'In ASP use Response.Write instead of MsgBox
Mailer.LicenseKey = "put your license key here"
Mailer.ServerName = "mail.server.com"
Mailer.UserName = "MyName"
Mailer.Password = "MyPassword"
Mailer.AuthMethod = 1 ' PLAIN ESMTP authentication
If Mailer.Connect Then
  Mailer.Message.ToAddr = "bill@yoursite.com"
  Mailer.Message.FromAddr = "joe@mysite.com"
  Mailer.Message.Subject = "Hello"
  Mailer.Message.ImportBodyText "C:\docs\letter.htm", True
  Mailer.Send
  Mailer.Disconnect
Else
  ' Server not available, PLAIN is not supported or username/password is incorrect
  MsgBox Mailer.ErrDesc 
End If

See Also:

ServerName Property
Domain Property
Message.FromAddr Property
PortNumber Property
UserName Property
Password Property
AuthMethod Property
Disconnect Method


Copyright 2002-2008, AfterLogic Corporation. All rights reserved.