As we continue to integrate the Gmail API into 4D Netkit, we’re bringing you a comprehensive set of commands to seamlessly manage your emails.
With 4D v20 R3, we’re introducing new commands that empower you to effortlessly retrieve the list of labels, get emails, and efficiently remove them.
Let’s learn more!
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($credentials)
$google:=cs.NetKit.Google.new($oAuth2; {mailType: "JMAP"})
Get label list
You can get the mail label collection by using the .getLabelList() function:
$labelList:=$google.mail.getLabelList()
// Collection with all the mail labels
$labels:=$labelList.labels
You get a collection that contains, for each label, label name, id, and type:
Get mails
You can get the mail Ids of your mailbox by using the .getMailIds() function. For example, if you want to retrieve all the mail present in the Inbox label:
$mailIds:=$google.mail.getMailIds({labelIds: ["INBOX"]})
To get the mail content, use the .getMail() function. For example, if you want to get the most recent mail of your Inbox label:
$mail:=$google.mail.getMail($mailIds.mailIds.first().id)
delete emails
You can move to trash or delete permanently your mails with the .delete() function:
// Delete permanently a mail
$status:=$google.mail.delete($mailIds.mailIds.first().id; True)
// Move a mail to the trash
$status:=$google.mail.delete($mailIds.mailIds.first().id; False)
Check out this feature with the HDI and the documentation for more details!