It looks like the error is happening on line 11 of your code, where you're trying to call the getLabels() function on a message object.
The error message "TypeError: message.getLabels is not a function" suggests that the getLabels() function is not a valid function for the message object.
One possibility is that the message object is not actually a valid message object, but instead is undefined or null. This could happen if there are no messages in a particular thread, for example.
To troubleshoot this issue, you might want to add some logging statements to your code to help you understand what's going on. For example, you could add a Logger.log() statement to output the message object and see what it contains.
You might also want to double-check that your Gmail labels are set up correctly and that the label you're using ('ZZZ - Self-Service Bin') actually exists and is applied to the messages you're trying to process.
--About Ascential plc
Ascential delivers specialist information, analytics and ecommerce optimisation platforms to the world's leading consumer brands and their ecosystems.
Our world-class businesses improve performance and solve problems for our customers by delivering immediately actionable information combined with visionary longer-term thinking across Digital Commerce, Product Design and Marketing. We also serve customers across Retail & Financial Services.
With over 3,000 employees across five continents, we combine local expertise with a global footprint for clients in over 120 countries.
Ascential is listed on the London Stock Exchange.
The information in or attached to this email is confidential and may be legally privileged. If you are not the intended recipient of this message, any use, disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you have received this message in error, please notify the sender immediately by return email and delete this message and any copies from your computer and network. Ascential does not warrant that this email and any attachments are free from viruses and accepts no liability for any loss resulting from infected email transmissions.
Ascential reserves the right to monitor all email through its networks. Any view expressed may be those of the originator and not necessarily of Ascential plc. Please be advised all phone calls may be recorded for training and quality purposes and by accepting and/or making calls to us you acknowledge and agree to calls being recorded.
Ascential plc, number 9934451 (England and Wales). Registered Office: 33 Kingsway, London, WC2B 6UF.
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/fed6a569-e821-4c5c-800c-5d8ad2b5ae04n%40googlegroups.com.