I am using Node.js, Gmail and Gmails API.
I am trying to read messages using gmails API.
To do this I:
async function getMessages(auth){
const gmail = google.gmail({version: 'v1', auth});
let theMessages = await gmail.users.messages.list({
userId:"me",
maxResults:10
})
let theIds = theMessages.data.messages
let theId = theIds[0].id
let response = await gmail.users.messages.get({
userId:"me",
id:theId
})
let theData = response.data
}
However the response i get is an obeject with this information:
historyId:"1"
id:"1"
internalDate:"1"
labelIds:Array(4) ["UNREAD", "IMPORTANT", "SENT", …]
payload:Object {partId: "", mimeType: "multipart/alternative", filename: "", …}
body:Object {size: 0}
__proto__:Object {constructor: , __defineGetter__: , __defineSetter__: , …}
sizeEstimate:578
snippet:"Hey"
threadId:"1"
__proto__:Object {constructor: , __defineGetter__: , __defineSetter__: , …}
filename:""
headers:Array(7) [Object, Object, Object, …]
mimeType:"multipart/alternative"
partId:""
parts:Array(2) [Object, Object]
How do i get the body of an email from this information. I've tried looking at the body attribute, but only find a size:0
. Part of the message is there as a snippet
, but obviously the full message isn't.
any help is appreciated.