5

I am trying to send emails for salesforce with attachments

    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);

I am getting error like

<AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

can any body help me

2
  • Sorry Sunny, didn't realise it was just a formatting issue in the question!
    – Matt Lacey
    Commented Sep 26, 2014 at 6:53
  • Hey Sunny, where did you end up with this? I'm having some similar issues.
    – Jose
    Commented Dec 5, 2014 at 5:32

0

You must log in to answer this question.

Browse other questions tagged .