We understand the significance of email communication and recognize that sending emails is a frequent requirement in modern applications. Numerous individuals who use Gmail have expressed their desire for an API that facilitates email sending through Gmail API. The integration of OAuth 2.0 was essential to establish a connection with the Gmail server.
We are pleased to announce that we will be venturing into Gmail management and implementing a ‘send email’ command.
Account connection
Before creating an email, we will create an OAuth 2.0 connection object and a Google object.
var $oAuth2 : cs.NetKit.OAuth2Provider
var $google : cs.NetKit.Google
$oAuth2:=cs.NetKit.OAuth2Provider.new($param)
$google:=cs.NetKit.Google.new($oAuth2; {mailType: "JMAP"})
Send email
Now that the OAuth 2.0 connection is ready, we can send an email using the mail.send() function of the $google object we create before:
// Email creation
$email:=New object
$email.from:="youremail@gmail.com"
$email.to:="destinationmail@mail.com"
$email.subject:="Test Gmail API"
$email.textBody:="this is a Gmail API test"
// Email sending
$status:=$google.mail.send($email)
Check out this feature with the HDI above and the documentation for more details!