My Code follows,(above code is same as given in the example of nodejs in google developer site.)
function listLabels(auth) {
var gmail = google.gmail({ auth: auth, version: 'v1' });
var emails = gmail.users.messages.list({
includeSpamTrash: false,
maxResults: 500,
q: "",
userId: 'me'
}, function (err, results) {
console.log(results.messages);
});
}
I'm getting array of objects containing IDs and threadIds
Now, if i input these IDs
into these
function getMessage(messageId,auth) {
var requestt = google.gmail({ auth: auth, version: 'v1' }).users.messages.get({
'userId': 'me',
'id': messageId
});
console.log(requestt)
requestt.execute(function(response){
console.log(response);
});
}
I am getting error,
TypeError: requestt.execute is not a function
at getMessage (/home/jay/Projects/gmailwebapi/index.js:122:11)
at /home/jay/Projects/gmailwebapi/index.js:113:7
at OAuth2Client._postRequest (/home/jay/Projects/gmailwebapi/node_modules/google-auth-library/lib/auth/oauth2client.js:381:3)
at postRequestCb (/home/jay/Projects/gmailwebapi/node_modules/google-auth-library/lib/auth/oauth2client.js:343:10)
at Request._callback (/home/jay/Projects/gmailwebapi/node_modules/google-auth-library/lib/transporters.js:103:7)
at Request.self.callback (/home/jay/Projects/gmailwebapi/node_modules/google-auth-library/node_modules/request/request.js:198:22)
at emitTwo (events.js:100:13)
at Request.emit (events.js:185:7)
at Request.<anonymous> (/home/jay/Projects/gmailwebapi/node_modules/google-auth-library/node_modules/request/request.js:1057:14)
at emitOne (events.js:95:20)
You could use the callback the same way you do when you list messages:
function getMessage(messageId, auth) {
var gmail = google.gmail({ auth: auth, version: 'v1' });
gmail.users.messages.get({
'userId': 'me',
'id': messageId
}, function (err, result) {
console.log(result);
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With