2013-07-15 138 views
1

我们使用AWS SES从C#应用程序发送电子邮件。我们有大小9.28MB的附件(PDF文件),当我们试图用附件发送电子邮件,它抛出以下异常:从AWS SES发送附件少于10 MB的电子邮件

System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at Amazon.Runtime.Internal.Transform.UnmarshallerContext.Read() at Amazon.Runtime.Internal.Transform.ErrorResponseUnmarshaller.Unmarshall(UnmarshallerContext context) at Amazon.SimpleEmail.Model.Transform.SendRawEmailResponseUnmarshaller.UnmarshallException(UnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) at Amazon.Runtime.AmazonWebServiceClient.processWebException[X,Y](String requestName, WebException we, HttpWebRequest webRequest, IResponseUnmarshaller`2 unmarshaller, IRequest`1 request, Int32 retries) at Amazon.Runtime.AmazonWebServiceClient.Invoke[X,Y](IRequest`1 request, AbstractAWSSigner signer, IResponseUnmarshaller`2 unmarshaller) at Amazon.SimpleEmail.AmazonSimpleEmailServiceClient.SendRawEmail(SendRawEmailRequest sendRawEmailRequest) at MyApp.AmazonSESWrapper.SendRawEmail(String awsAccessKey, String awsSecretKey, List`1 to, List`1 cc, List`1 bcc, String senderEmailAddress, String replyToEmailAddress, String subject, String body, String text, String filePath, String exceptionDetails) 

但是,当我们发送7.50MB word文档作为附件,我们越来越以下异常:

Amazon.SimpleEmail.AmazonSimpleEmailServiceException: Message length is more than 10485760 bytes long: '10788624'. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at Amazon.Runtime.AmazonWebServiceClient.Invoke[X,Y](IRequest`1 request, AbstractAWSSigner signer, IResponseUnmarshaller`2 unmarshaller) --- End of inner exception stack trace --- at Amazon.Runtime.AmazonWebServiceClient.processWebException[X,Y](String requestName, WebException we, HttpWebRequest webRequest, IResponseUnmarshaller`2 unmarshaller, IRequest`1 request, Int32 retries) at Amazon.Runtime.AmazonWebServiceClient.Invoke[X,Y](IRequest`1 request, AbstractAWSSigner signer, IResponseUnmarshaller`2 unmarshaller) at Amazon.SimpleEmail.AmazonSimpleEmailServiceClient.SendRawEmail(SendRawEmailRequest sendRawEmailRequest) at 

从论坛和常见问题,它说,最大附件大小为10MB,但小于10MB的附件时,也会发生错误。

https://forums.aws.amazon.com/thread.jspa?messageID=346305

http://aws.amazon.com/ses/faqs/#49

这个请建议。

+0

的AWS文档就此事( http://docs.aws.amazon.com/ses/latest/DeveloperGuide/limits.html#limits-message)表示base64编码之后的消息(包含附件)的总大小不应超过10mb。当你base64编码9.28mb的数据时,尺寸跳跃到10mb以上 - 大概14mb左右。 – king

回答

2

还有总体消息大小限制,也是10M。按http://aws.amazon.com/ses/faqs/

亚马逊SES将接受电子邮件多达10 MB大小。此 包括属于该消息的任何附件。

因此,您必须确保您的请求符合这些限制。

(我个人认为它的亚马逊API抛出的错误。:万一“XmlException。缺少根元素”时,邮件大小大大超过了限制这完全是误导)

+0

true http://docs.aws.amazon.com/ses/latest/DeveloperGuide/limits.html – Dave