无法使用Office 365 REST API发送大邮件

无法使用Office 365 REST API发送大邮件

问题描述:

我正在使用JavaScript发出POST请求以使用xhr创建到Office 365的消息(或者使用法拉第gem发出POST请求-Ruby on Rails).我的流程是将文件编码为base64并创建一个包含所有内容的JSON附件(已编码),然后发布到https://outlook.office.com/api/v1.0/me/sendmail.

I'm using JavaScript to make a POST request to create a message to Office 365 with xhr (Or using Faraday gem to make POST request - Ruby on Rails).My flow is encode file to base64 and create a JSON contain all attachments(encoded) then POST to https://outlook.office.com/api/v1.0/me/sendmail.

var endpointUrl = "https://outlook.office.com/api/v1.0/me/sendmail";
    var xhr = new XMLHttpRequest();
    xhr.open("POST", endpointUrl);
    xhr.setRequestHeader("Authorization", "Bearer " + token);
    xhr.setRequestHeader("content-type", "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8");
    xhr.send(JSON.stringify(result));
}

此代码可以发送带有大约22.5MB附件的消息,但是如果所有附件的大小都超过23MB,我将收到404错误响应,并且控制台将写入:

This code can send message with about 22,5MB attachments, but if all attachments have more than 23MB, I got 404 error reponse and the cosole write:

XMLHttpRequest无法加载 https://outlook.office.com/api/v1.0/me/sendmail .不 请求中存在"Access-Control-Allow-Origin"标头 资源.因此,不允许使用来源' http://localhost:3000 使用权.响应的HTTP状态代码为404.

XMLHttpRequest cannot load https://outlook.office.com/api/v1.0/me/sendmail. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404.


message size restrictions设置为最大153600 有人可以帮我吗?谢谢!


Alr set message size restrictions to max 153600 Could someone help me? Thank you !

看起来确实遇到了有效载荷最大大小的限制.当前的限制为37 MB,并通过outlook.office.com强制实施了较低的限制.我们已经打开了一个工作项以增加此限制,以允许我们可以在Office 365中存储的最大附件大小(150 MB),但是您需要等待该附件完成后才能发送尝试大小的邮件发送.

It does look like you are running into a limit on the max size of the payload. The limit currently is 37 MB and a lower limit is being enforced through outlook.office.com. We have opened a work item to increase this limit to allow the max attachment size we can store in Office 365 (150 MB), but you will need to wait for that to be completed before you can send messages of the sizes you are attempting to send.