我試圖用附件發送郵件通過使用Amazon SES亞馬遜SES帶附件
HttpRequest httpReq = new HttpRequest();
httpReq.setMethod('POST');
httpReq.setEndpoint('https://email.us-east-1.amazonaws.com');
Blob bsig = Crypto.generateMac('HmacSHA256', Blob.valueOf(awsFormattedNow), Blob.valueOf(secret));
httpReq.setHeader('X-Amzn-Authorization','AWS3-HTTPS AWSAccessKeyId='+key+', Algorithm=HmacSHA256, Signature='+EncodingUtil.base64Encode(bsig));
httpReq.setHeader('Date',awsFormattedNow);
httpReq.setHeader('From','[email protected]');
httpReq.setHeader('To','[email protected]');
httpReq.setHeader('Subject','Hello');
httpReq.setHeader('Accept-Language','en-US');
httpReq.setHeader('Content-Language','en-US');
httpReq.setHeader('Content-Type','multipart/mixed;boundary=\"_003_97DCB304C5294779BEBCFC8357FCC4D2\"');
httpReq.setHeader('MIME-Version','1.0');
// httpReq.setHeader('Action','SendRawEmail');
String email = 'Action=SendRawEmail';
email += '--_003_97DCB304C5294779BEBCFC8357FCC4D2 \n Content-Type: text/plain; charset="us-ascii" \n Content-Transfer-Encoding: quoted-printable \n';
email +='Hi Andrew. Here are the customer service names and telephone numbers I promised you.';
httpReq.setBody(email);
System.debug(httpReq.getBody());
Http http = new Http();
HttpResponse response = http.send(httpReq);
我收到錯誤,如
<AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
請請幫我在哪裏,我做錯了發送電子郵件。在此先感謝
嗨@邁克爾,我意識到看到這個帖子後的錯誤,我無法理解其進入頭部,哪些不是,以及如何設置邊界(頭或身體)。你能不能給我一些示例代碼來發送沒有附件的原始消息,這樣我會更清楚。感謝您的回覆 – Sunny 2014-09-27 07:49:35
嗨@邁克爾,我做到了。非常感謝您寶貴的建議,幫助了我很多 – Sunny 2014-09-28 12:11:46