OAuth 2.0 authentication

Visual Basic Code | ASP Code

The sample sends HTML e-mail using OAuth 2.0 access token (which you need to obtain from a mail service provider using their API).

SMTP.AuthMethod is a key property of the sample.

MailBee Objects ships with VBScript OAuth 2.0 samples for Gmail and Office 365. You can find it in My Documents/MailBee Objects/Samples/OAuth2_VBScript folder.

Note that the mail service provider's APIs for obtaining access tokens can be different for web and Windows applications.

[Visual Basic]:

Dim objSMTP

' Create mailer component
Set objSMTP = CreateObject("MailBee.SMTP")

' Unlock SMTP component
objSMTP.LicenseKey = "put your license key here"

' Set SMTP server name
objSMTP.ServerName = "mail.server.com"

' OAuth 2.0 authentication
objSMTP.AuthMethod = 8
objSMTP.UserName = "username" ' Usually, email address
objSMTP.Password = "access_token" ' You get it from the mail service provider using their proprietary API

' Set message properties
objSMTP.FromAddr = "me@mydomain.com"
objSMTP.ToAddr = "you@yourdomain.com"
objSMTP.Subject = "Message in HTML format"

' Set HTML format for the body
objSMTP.BodyFormat = 1

' Place HTML contents into the body
objSMTP.BodyText = "<html>This word is <b>bold</b></html>"

' Send it!
objSMTP.Send

[ASP]:

<%
Dim objSMTP

' Create mailer component
Set objSMTP = Server.CreateObject("MailBee.SMTP")

' Unlock SMTP component
objSMTP.LicenseKey = "put your license key here"

' Set SMTP server name
objSMTP.ServerName = "mail.server.com"

' OAuth 2.0 authentication
objSMTP.AuthMethod = 8
objSMTP.UserName = "username" ' Usually, email address
objSMTP.Password = "access_token" ' You get it from the mail service provider using their proprietary API

' Set message properties
objSMTP.FromAddr = "me@mydomain.com"
objSMTP.ToAddr = "you@yourdomain.com"
objSMTP.Subject = "Message in HTML format"

' Set HTML format for the body
objSMTP.BodyFormat = 1

' Place HTML contents into the body
objSMTP.BodyText = "<html>This word is <b>bold</b></html>"

' Send it!
objSMTP.Send
%>
See Also:
AuthMethod Property

 


Send feedback to AfterLogic
Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.