首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Gmail的messages.send方法中电子邮件体的大小限制是什么?

Gmail的messages.send方法中电子邮件体的大小限制是什么?
EN

Stack Overflow用户
提问于 2015-07-02 14:31:50
回答 4查看 1.5K关注 0票数 2

我使用官方的.net api客户端通过messages.send方法发送带有附件的电子邮件。当我附加一个大小超过5mb的文件时,

代码语言:javascript
运行
复制
[JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.]
   Newtonsoft.Json.JsonTextReader.ParseValue() +1187
   Newtonsoft.Json.JsonTextReader.ReadInternal() +65
   Newtonsoft.Json.JsonTextReader.Read() +28
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter) +237
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) +783
   Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) +293
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) +274
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value, JsonSerializerSettings settings) +57
   Google.Apis.Json.NewtonsoftJsonSerializer.Deserialize(String input) in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Core\Apis\Json\NewtonsoftJsonSerializer.cs:120
   Google.Apis.Services.<DeserializeError>d__8.MoveNext() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis\Apis\Services\BaseClientService.cs:286

[GoogleApiException: An Error occurred, but the error response could not be deserialized]
   Google.Apis.Requests.ClientServiceRequest`1.Execute() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:102

我认为客户端使用元数据URI,仅用于元数据请求。A将尝试另一个选项:上传URI,用于媒体上传请求。看起来,电子邮件大小的限制导致了客户端库中解析错误响应的例外。

所以,第一个问题是:有尺寸限制吗?第二,没有关于如何通过客户端使用不同上传方式的信息,您知道任何客户端库文档吗?

更新:我黑掉了由

代码语言:javascript
运行
复制
var request = gmailService.Users.Messages.Send(message, AccountUserId);

要去https://www.googleapis.com/gmail/v1/users/me/messages/send。正如我所设想的,它没有使用媒体上传请求。

EN

回答 4

Stack Overflow用户

发布于 2016-10-25 16:02:41

最后,我限制了附件的总大小。这是代码片段。

班级级别:

代码语言:javascript
运行
复制
public const int MaxAttachmentsSize = 5 * 1024 * 1024;

方法级别:

代码语言:javascript
运行
复制
var attachmentsSize = 0;
foreach (var attachment in attachments)
{
    attachmentsSize += attachment.Item1;
    if (attachmentsSize > MaxAttachmentsSize) break;
    mailMessage.Attachments.Add(attachment.Item2);
}
票数 1
EN

Stack Overflow用户

发布于 2015-07-02 14:56:58

整个消息在MB中是有限制的。Google允许您发送相当大的电子邮件,但是如果您的服务因为连接速度太长而发送时可能会超时。

根据这个google文档,它是35 it:

google发送文档

票数 0
EN

Stack Overflow用户

发布于 2015-07-06 17:27:11

对于任何超过几MB的内容(上传),您都应该使用该方法的/upload版本,否则您可能会遇到这些大小限制。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31187414

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档