Failed sending mail through google api with javascript

After days i had found the answer by my own. The problem was that the ‘message’ in the body only can be used when you send an attachment in the email.

If you have no attachment the query looks like I wrote down here

var mail= base64EncodedEmail;
console.log(mail);
var request = gapi.client.gmail.users.messages.send({
  'userId': "me",
  'resource': {
      'raw': mail
    }
});
request.execute(function(response){
 console.log(response);
});

Leave a Comment