2013-07-15 117 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