Skip to content

Instantly share code, notes, and snippets.

@theirf
Created September 11, 2014 17:43
Show Gist options
  • Save theirf/71464ac6e9ead6425074 to your computer and use it in GitHub Desktop.
Save theirf/71464ac6e9ead6425074 to your computer and use it in GitHub Desktop.
gapi.client.load('gmail', 'v1', function(){
listThreads('me', function(dataResult){
$.each(dataResult, function(i, item){
getThreads('me', item.id, function(dataMessage){
var temp = dataMessage.messages[0].payload.headers;
$.each(temp, function(j, dataItem){
if(dataItem.name == 'From'){
console.log(dataItem.value);
}
});
});
});
});
@ansariabr
Copy link

add the getThreads() method as

function getThread(userId, threadId, callback) { var request = gapi.client.gmail.users.threads.get({ 'userId': userId, 'id': threadId }); request.execute(callback); }

@theirf
Copy link
Author

theirf commented Sep 12, 2014

I am using your getThread() function and now getting that dataMessage.messages is undefined.

gapi.client.load('gmail', 'v1', function(){
     listThreads('me', function(dataResult){
             $.each(dataResult, function(i, item){
                 getThread('me', item.id, function(dataMessage){
                     var temp = dataMessage.messages[0].payload.headers;
                      $.each(temp, function(j, dataItem){
                          if(dataItem.name == 'From'){
                           console.log(dataItem.value);
                      }  
                     });
                });
            });
        });
    });

@MaximusSu
Copy link

Hi theirf, have you found the solution for your Gmail Api problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment