【发布时间】:2019-11-20 07:12:50
【问题描述】:
获取不带附件的邮件 我正在使用 microsoft graph sendMail。 我需要同时添加一个附件。 我在请求正文的消息中添加了附件对象。 但是收到了没有附件的邮件。 我在关注: https://docs.microsoft.com/en-us/graph/api/resources/fileattachment?view=graph-rest-1.0 PFB 我的代码。
function sendAttachment(accessToken) {
const attachments = [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"contentBytes": "",
"name": "example.jpg"
}
];
var message=
{ subject: 'It\'s working ',
body:
{ contentType: 'Text',
content: 'Sending mail using microsoft graph and Outh2.0' },
toRecipients: [ { emailAddress: { address: '' } } ],
ccRecipients: [ { emailAddress: { address: '' } } ]
};
message["attachments"] = attachments;
var options = {
method: 'POST',
url: 'https://graph.microsoft.com/v1.0/users/xyz@xyz.com/sendMail',
headers:
{ 'Cache-Control': 'no-cache',
Authorization: 'Bearer '+ accessToken,
'Content-Type': 'application/json' },
body:JSON.stringify({
"message": message,
"SaveToSentItems": "false"
}),
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log("--attachment--");
});
}
我在这里错过了什么??
【问题讨论】:
标签: javascript node.js microsoft-graph-api microsoft-graph-mail exchange-basicauth