0

I have the following Gmail API script:

function listMsgs() {
  var response = Gmail.Users.Messages.list('me');
  Logger.clear();
  for(var i=0; i<response.messages.length; i++) {
    var message = response.messages[i];

    var response1 = Gmail.Users.Messages.get({
      'userId': 'me',
      'id': message.id,
      'format': 'full'
    });

    Logger.log("1) %s", message.id);
    Logger.log("2) %s", message.threadId);
    Logger.log("3) %s", response1.snippet);
  }
}

I get an error Invalid number of arguments provided. Expected 2-3 only (line 7, file "Code")

Can anyone assist with this script? Thank you.

H. Ferrence
  • 7,906
  • 31
  • 98
  • 161

1 Answers1

1

You error Invalid number of arguments provided. Expected 2-3 only (line 7, file "Code") means that the number of arguments in the call to the procedure wasn't the same as the number of required arguments expected by the procedure. Check the argument list in the call against the procedure declaration or definition. It's also stated in this SO question you can use the Advanced Gmail Service that allows scripts to find and modify threads, messages, and labels in a Gmail mailbox. Remember that the service must be enabled before use. Hope this helps!

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59