• <i id='H2rjf'><tr id='H2rjf'><dt id='H2rjf'><q id='H2rjf'><span id='H2rjf'><b id='H2rjf'><form id='H2rjf'><ins id='H2rjf'></ins><ul id='H2rjf'></ul><sub id='H2rjf'></sub></form><legend id='H2rjf'></legend><bdo id='H2rjf'><pre id='H2rjf'><center id='H2rjf'></center></pre></bdo></b><th id='H2rjf'></th></span></q></dt></tr></i><div id='H2rjf'><tfoot id='H2rjf'></tfoot><dl id='H2rjf'><fieldset id='H2rjf'></fieldset></dl></div>
    <tfoot id='H2rjf'></tfoot>
    • <bdo id='H2rjf'></bdo><ul id='H2rjf'></ul>
      <legend id='H2rjf'><style id='H2rjf'><dir id='H2rjf'><q id='H2rjf'></q></dir></style></legend>

        <small id='H2rjf'></small><noframes id='H2rjf'>

      1. 发送带有附件 Microsoft Graph 的邮件不起作用

        时间:2023-10-21

        <small id='kaSqz'></small><noframes id='kaSqz'>

      2. <legend id='kaSqz'><style id='kaSqz'><dir id='kaSqz'><q id='kaSqz'></q></dir></style></legend>

          <bdo id='kaSqz'></bdo><ul id='kaSqz'></ul>

          <i id='kaSqz'><tr id='kaSqz'><dt id='kaSqz'><q id='kaSqz'><span id='kaSqz'><b id='kaSqz'><form id='kaSqz'><ins id='kaSqz'></ins><ul id='kaSqz'></ul><sub id='kaSqz'></sub></form><legend id='kaSqz'></legend><bdo id='kaSqz'><pre id='kaSqz'><center id='kaSqz'></center></pre></bdo></b><th id='kaSqz'></th></span></q></dt></tr></i><div id='kaSqz'><tfoot id='kaSqz'></tfoot><dl id='kaSqz'><fieldset id='kaSqz'></fieldset></dl></div>

              <tbody id='kaSqz'></tbody>
                  <tfoot id='kaSqz'></tfoot>
                  本文介绍了发送带有附件 Microsoft Graph 的邮件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在制作一个应用程序,如 通过这篇文章.

                  I am making an application that sends emails from a User as described by this article.

                  一切都按预期工作,除了我尝试包含附件时.电子邮件发送,但没有附件.我不确定问题是什么,因为我已经尝试了几乎所有我可以在网上找到的东西.我已确保我发送的文件以 base64 正确编码.

                  Everything is working as expected, except for when I try to include an attachment. The email sends, but without the attachment. I'm not sure what the problem is as I've tried pretty much everything I could find online. I have made sure the file I am sending is properly encoded in base64.

                  var message = {
                      "subject": subject,
                      "hasAttachments":true,
                      "body": {
                          "contentType": "Text",
                          "content": emailBody
                      }, 
                      "toRecipients": toRecipients,
                      ccRecipients, 
                      bccRecipients
                  };
                  
                  
                  function sendMailRequest(access_token, message, uriSend, file, base64, callback){
                  const attachments = [{
                  '@odata.type': '#microsoft.graph.fileAttachment',
                  "contentBytes": base64
                  "name": "example.jpg"
                  }];
                  
                  // Configure the request
                  var options2 = {
                  "url": uriSend,
                  "method": 'POST',
                  "headers": { 
                      'Authorization': access_token,
                      'Content-Type': 'application/json'
                  },
                  "body": JSON.stringify({
                      "message": message, 
                      "SaveToSentItems": "true",
                      "Attachments": attachments
                  })
                  }
                  

                  推荐答案

                  附件位于 message JSON 内部,而不是外部.这应该有效:

                  Attachments go inside the message JSON, not outside of it. This should work:

                  function sendMailRequest(access_token, message, uriSend, file, base64, callback) {
                    const attachments = [
                      {
                        "@odata.type": "#microsoft.graph.fileAttachment",
                        "contentBytes": base64
                        "name": "example.jpg"
                      }
                    ];
                  
                    message["attachments"] = attachments;
                  
                    // Configure the request
                    var options2 = {
                      "url": uriSend,
                      "method": "POST",
                      "headers": { 
                        "Authorization": access_token,
                        "Content-Type": "application/json"
                      },
                      "body": JSON.stringify({
                        "message": message, 
                        "SaveToSentItems": "true"
                      })
                    }
                    ...
                  }
                  

                  这篇关于发送带有附件 Microsoft Graph 的邮件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Rest Web 服务问题中使用 JSON 进行 jQuery Ajax POST 调用 下一篇:如何获取 Azure AD OAuth 登录的登录用户配置文件?

                  相关文章

                • <tfoot id='8yyld'></tfoot>
                • <small id='8yyld'></small><noframes id='8yyld'>

                • <legend id='8yyld'><style id='8yyld'><dir id='8yyld'><q id='8yyld'></q></dir></style></legend>
                    <bdo id='8yyld'></bdo><ul id='8yyld'></ul>
                  1. <i id='8yyld'><tr id='8yyld'><dt id='8yyld'><q id='8yyld'><span id='8yyld'><b id='8yyld'><form id='8yyld'><ins id='8yyld'></ins><ul id='8yyld'></ul><sub id='8yyld'></sub></form><legend id='8yyld'></legend><bdo id='8yyld'><pre id='8yyld'><center id='8yyld'></center></pre></bdo></b><th id='8yyld'></th></span></q></dt></tr></i><div id='8yyld'><tfoot id='8yyld'></tfoot><dl id='8yyld'><fieldset id='8yyld'></fieldset></dl></div>