Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting unread count in Sent Folder using Google Apps Script - GMail

Is there a way to get Unread Mail count in Sent Folder?

Basically, the feature I want is: When I reply to a message in mailing list that's filtered and doesn't pass my INBOX, I want all the subsequent replies to be reaching my INBOX.

The way I'm trying to accomplish is that if I see a Unread Mail in Sent folder, that means that there is a new mail in a thread I was involved. I'm saying this because I see those mails as unread when I click "Sent" in Gmail's web interface.

So, is there a way to get unread count for a system label?

Dirty way: One way I could accomplish this is creating a filter that selects all mails that has "from:" as my address and use that to get what I want. But, this way I'm creating a duplicate of which I don't feel good about!

like image 381
Abhijeet Rastogi Avatar asked Nov 18 '25 10:11

Abhijeet Rastogi


1 Answers

One of the wonderful things about GmailApp in Apps Script is the ability to use the same search features that you have in Gmail (quite powerful).

To see all unread messages in Sent folder, search with the following string

is:unread label:sent

Something like

  var query = 'is:unread label:sent'; 
  var threads = GmailApp.search(query);
like image 64
Srik Avatar answered Nov 19 '25 23:11

Srik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!