4D Blog

Home Product 4D NetKit: Retrieve Unread Email Counts for multiple labels in One Call with Gmail API

4D NetKit: Retrieve Unread Email Counts for multiple labels in One Call with Gmail API

November 6, 2024

Product

A lot of you use Gmail commands to show the number of unread emails in your app’s UI to let users know about new messages. So, starting with 4D 20 R7, we’ve upgraded Google.mail.getLabelList() function so that it can get the number of unread emails along with label properties for Gmail all at once to ensure optimal response times.

Gmail labels

To optimize the response time, the .getLabelList() function lets you get the total number of messages and unread messages, as well as the total number of threads and unread threads for multiple labels in one call. It now takes an object with 2 possible attributes to get this info:

  • Use the withCounters attribute to get the message and thread counters along with the standard label info:
$labelList:=$google.mail.getLabelList({withCounters: True})

  • Use the ids collection to specify which label you want to get. If you use the ids attribute, the message and thread counters are always returned:
// If you want to get only the INBOX and SENT information:
$myLabels:=$google.mail.getLabelList({ids: ["INBOX";"SENT"]})

blank

These enhancements make it easier for you to keep your users informed about their unread emails by providing all the necessary information in a single call. And as it is done in a single call, response times are optimal compared to what was possible before. This same improvement has also been applied to IMAP, allowing you to retrieve unread email counts and mailbox properties in a single call for optimal performance.

If you need further information, please consult the 4D Netkit documentation.

Discuss

Tags 20 R7, 21, 4D NetKit, Google

Latest related posts

  • January 9, 2026

    Session handling in 4D Qodly Pro

  • January 7, 2026

    Enhance your Desktop Interface with Web widgets using 4D Qodly Pro

  • January 7, 2026

    Embed Qodly pages in a 4D web area without extra cost

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

  • AI
  • 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 AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 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