I am trying to use the Gmail API to receive a user’s email, capture the subject and body of a message, and then display it on a web page. I will do other things, but this is the part that is difficult for me. I am using Angular.js.
Here is my API call:
function makeApiCall() { gapi.client.load('gmail', 'v1', function() { var request = gapi.client.gmail.users.messages.list({ labelIds: ['INBOX'] }); request.execute(function(resp) { var content = document.getElementById("message-list"); angular.forEach(resp, function(message) { var email = gapi.client.gmail.users.messages.get({'id': message.id});
So gapi.client.gmail.users.messages.list returns an array of my messages with their identification numbers. It works.
Calling gapi.client.gmail.users.messages.get({<specific message ID>}) calls this - {"B":{"method":"gmail.users.messages.get","rpcParams":{},"transport":{"name":"googleapis"}}} .
Not sure what it is, but trying to get the message payload ( email.payload.parts ) leads to undefined . So how can I get the content of the message?
In addition, I would suggest that if I could get the contents of the message, I would have to Base64 decode the contents to extract some English from it. Any suggestions for this would also be helpful. I found this: https://github.com/kvz/phpjs , but since I'm not sure how to go about getting the contents of the message so that I can decode it, so it’s not sure if this php.js helps in this regard.
javascript angularjs base64 gmail-api
eugene1832
source share