4D Blog

Home Product 4D Netkit: Get Labels And Emails From Gmail

4D Netkit: Get Labels And Emails From Gmail

October 19, 2023

Product

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!

HDI Google gets emails

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!

Discuss

Tags 21, 4D NetKit, Google, Mail, v20 R3

Latest related posts

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

  • April 29, 2025

    Discover your AI-powered writing assistant in 4D Write Pro

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy