There may be times when you find it necessary to keep an email as a template inside a designated label in your mailbox. With the release of 4D 20 R5, we have introduced a feature that allows you to add an email to a mailbox without sending it.
Account connection
Before appending 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($credentials)
$google:=cs.NetKit.Google.new($oAuth2; {mailType: "JMAP"})
Append an email
To append an email, you need to use the .append() function:
$status:=$google.mail.append($mail)
By default, the mail is created with a “DRAFT” label, but you can change it by passing a second parameter:
$status:=$google.mail.append($mail;["INBOX"])