0
目前我正在Chrome擴展我想特別是電子郵件(即MESSAGE_ID = 1543c2a6347d984c)附件數據獲取Gmail附件。我得到了email message_id也獲得了附件文件名(即abc.zip),但是如何獲得該附件並使用Ajax發送回我的服務器。如何使用JavaScript通過GET請求之前發送
function getAttachments(userId, message, callback) {
var parts = message.payload.parts;
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
if (part.filename && part.filename.length > 0) {
var attachId = part.body.attachmentId;
var request = gapi.client.gmail.users.messages.attachments.get({
'id': attachId,
'messageId': message.id,
'userId': userId
});
request.execute(function(attachment) {
callback(part.filename, part.mimeType, attachment);
});
}
}
}
調用
var userId="[email protected]"
var message_id="1543c2a6347d984d";
getAttachments(userId,message_id,function callback(filename,minetype,attachment){
console.log('File Name is '+filename);
console.log('MimeType is '+minetype);
});
錯誤: main.js:15遺漏的類型錯誤:無法讀取的未定義的屬性 '零件'(功能getAttachments 2號線)
究竟什麼是該解決方案?拉特的看到這[鏈接](https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get#examples) –
@DivyeshKanzariya,看到我的答案。 –
如何申請許可https://mail.google.com/ https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.readonly該豪宅 –