Messages unread

15 views
Skip to first unread message

Emeric HOCHART

unread,
Dec 12, 2019, 2:21:00 AM12/12/19
to Google Apps Script Community
Hi !
I have a problem with a webapp.
I want to know the number of messages's user unread.
When i get the active user, it's the good email but it's my number of messages unread.
The script is a web app set to "execute as me" (the developer)

My function :

/**
 * Get the number of messages unread
 */
function getNumberUnreadMail(){  
  // Get Active user
  var emailSession.getActiveUser().getEmail();
  // Get "Unread" Labels Informations
  var response = Gmail.Users.Labels.get(email,'UNREAD');
  // TODO : manage value of response & errors
  if(response){
    var unreadNumber = response.messagesUnread;
    // return Total Number of Messages Unread
    return unreadNumber;
  } else {
    Logger.log('Erreur');
  }
}
Reply all
Reply to author
Forward
0 new messages