4D Blog

Home Product 4D Netkit: Create, delete and update Gmail labels

4D Netkit: Create, delete and update Gmail labels

January 17, 2024

Product

Gmail labels provide a flexible way to categorize and organize emails, enabling personalized and efficient email management. Their use facilitates easy navigation and identification of messages, offering an enhanced user experience in email handling.

With this last set of functions that includes all the features to manage labels from the 4D v20 R4, you have in 4D NetKit a set of functions to manage your Gmail labels by programming.

HDI Google Manage Labels

Account connection

Before creating a label, 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"})

Create a label

Creating a new label is straightforward using the .createLabel() function. For instance, to create a ‘Backup’ label:

$status:=$google.mail.createLabel({name: "Backup"})
$labelId:=$status.label.id

Get label information

Retrieve label information, such as name, total message count, and unread messages, with the .getLabel() function:

$info:=$google.mail.getLabel($labelId)
$name:=$info.name
$emailNumber:=$info.messagesTotal
$unread:=$info.messagesUnread

Update a label

Update a previously created label using the .updateLabel() function. For example, rename it to ‘Backup 2024’:

$status:=$google.mail.updateLabel($labelId; {name:"Backup 2024"})

Delete a label

Deleting a label is done with the .deleteLabel() function:

$status:=$google.mail.deleteLabel($labelId)

In conclusion, leveraging the Gmail API’s label management features in 4D offers a seamless way to organize and streamline email-related workflows. The ability to create, retrieve, update, and delete labels effortlessly improves email categorization customization and overall efficiency. Developers can refer to the official documentation for detailed implementation and exploit the full potential of label operations in Gmail’s integration with 4D.

Discuss

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

Latest related posts

  • July 16, 2025

    Recursive Dependency Management: Smarter, Deeper, Safer

  • July 16, 2025

    Stricter class-based typing for objects

  • July 16, 2025

    ORDA – Get started with the touched event

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 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Data explorer Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming 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 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Data explorer Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming 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