If you prefer to relay email through Google Workspace (formerly G Suite) or Gmail instead of using our local mail server, you can configure CDOSYS to connect to Google's SMTP servers.
Google no longer supports "Less Secure Apps" using your standard account password. To use the code below, you must:
The following VBScript configures CDOSYS to use Google's SMTP server on port 465 with SSL enabled.
<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'Configuration Constants
Const cdoSendUsingPort = 2
Const cdoBasicAuth = 1
'Get the configuration fields
Dim iConf
Set iConf = ObjSendMail.Configuration.Fields
'Set the configuration for GMAIL / Google Workspace
With iConf
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
'Authentication
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasicAuth
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourname@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourAppPassword" ' Use App Password here!
.Update
End With
'Create the message
With ObjSendMail
.To = "recipient@external.com"
.From = "yourname@gmail.com" 'Must match the authenticated account
.Subject = "Test Email via Gmail"
.TextBody = "This message was sent using CDOSYS and Google SMTP."
.Send
End With
Set ObjSendMail = Nothing
%>