我目前正在基于此线程使用gmail API
https://stackoverflow.com/a/31792244/6766279
如果我只需要撰写新电子邮件,一切正常,但是如果我需要回复,我不知道该怎么办。我尝试使用threadId更改数据,并收到错误['Recipient address required.'
/* Send the mail! */
$.ajax({
type: "POST",
url: "https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=multipart",
contentType: "message/rfc822",
beforeSend: function (xhr, settings) {
xhr.setRequestHeader('Authorization', 'Bearer ' + ACCESS_TOKEN);
},
data: {
raw: mail,
threadId: thread.id
},
success: function (res) {
resolve(res)
},
error: function (error) {
console.log('ERROR:', error.responseJSON.error.message);
window.open(`${location.origin}/api/google/rest/verify`, "", "width=500, height=500");
}
});
我真的需要帮助。
/* Send the reply! */
$.ajax({
type: "POST",
url: "https://www.googleapis.com/gmail/v1/users/me/messages/send",
headers: {
'Content-Type' : 'application/json',
'Authorization': 'Bearer ' + ACCESS_TOKEN,
},
data: JSON.stringify({
raw: btoa(mail).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''),
threadId : threadId
}),
success: function(res){
console.log(res)
},
error: function(error){
console.log('ERROR:', error);
}
});
已解决,