Knowledge Base

How can I send e-mail through Gmail with ActiveX version (VB6, classic ASP)

Gmail accepts only secure SSL connections, and thus you should use MailBee SMTP component with SSL object.

According to this page, as of May 30, 2022 Google is disabling username/password based access to Gmail accounts so it may no longer be possible for you to access Gmail account with MailBee using your email address and account password. However, you can create an app password to be used with MailBee.

1. First of all, you need to enable 2-Step Verification in your Google account settings.

It is required, as Google only allows generating passwords for apps on accounts that have 2-Step Verification enabled.

2. Navigate to App Password section of your Google account security page and generate app password.

Select "Mail" as app type, "Other" as device and provide an app name - it will only be used as a display name for password in Google.

3. Once the password is created, simply use it instead of mail account password when accessing Gmail:

Visual Basic

Set SMTP = CreateObject("MailBee.SMTP")
set SSL = CreateObject("MailBee.SSL")

SMTP.EnableLogging = True
SMTP.LogFilePath = "C:\Documents\gmail.log"
SMTP.ClearLog

SMTP.LicenseKey = "Your SMTP key"

Set SMTP.SSL = SSL

SMTP.UserName = "gmail-login"
SMTP.Password = "gmail-app-password"
SMTP.AuthMethod = 2

SMTP.ServerName = "smtp.gmail.com"

SSL.UseStartTLS = True

SMTP.FromAddr = "user@gmail.com"
SMTP.ToAddr = "joe@company.com"
SMTP.Subject = "Report"

If Not SMTP.Send Then MsgBox SMTP.ErrDesc

ASP

Set SMTP = Server.CreateObject("MailBee.SMTP")
set SSL = Server.CreateObject("MailBee.SSL")

SMTP.EnableLogging = True
SMTP.LogFilePath = "C:\Documents\gmail.log"
SMTP.ClearLog

SMTP.LicenseKey = "Your SMTP key"

Set SMTP.SSL = SSL

SMTP.UserName = "gmail-login"
SMTP.Password = "gmail-app-password"
SMTP.AuthMethod = 2

SMTP.ServerName = "smtp.gmail.com"

SSL.UseStartTLS = True

SMTP.FromAddr = "user@gmail.com"
SMTP.ToAddr = "joe@company.com"
SMTP.Subject = "Report"

If Not SMTP.Send Then Response.Write SMTP.ErrDesc

Another approach you may wish to use is OAuth2. Once you have MailBee installed, you can find a sample and readme file for that under Documents\MailBee Objects\Samples\OAuth2_VBScript directory.