javascriptgoogle-apps-scriptgmailgmail-apigmail-addons

Gmail Apps script function to display Browser MsgBox from GMail Addon


I have the following working code which validates a list of recipients based on specific conditions. However, I'm looking to replace the resulting "Logger.log" actions with "Browser.msgbox" actions, and for some reason, GMail App Addons are not allowing me to do so:

function validateRecipients(e) {
  var toEmails = e.draftMetadata.toRecipients, ccEmails = e.draftMetadata.ccRecipients, bccEmails = e.draftMetadata.bccRecipients, domains = [], uniqueDomains = [];
  var allEmails = toEmails.concat(ccEmails, bccEmails);
  for (var i = 0; i < allEmails.length; i++) {
    domains[i] = allEmails[i].split("@").pop().split(".")[0]; 
  }  
  uniqueDomains = domains.filter(listUnique);
  if(uniqueDomains.length <= 2 && uniqueDomains.indexOf("verasafe") != -1) {
    Logger.log("This Message is Good to Go");
  }

  else if(uniqueDomains.length == 0) {
    Logger.log("This Message has no recipients");
  }

  else {
    Logger.log("Please Validate Receipients of this Message and Try again");
  }
}

Solution

  • You cannot use Browser.msg or any of the UI classes with Gmail.

    However, there is a new feature called Card Service that is meant to be used for the creation of UI for Gmail Addons.

    Hope this helps!