public with sharing class AWS_SES {
public String endpoint = 'https://email.us-east-1.amazonaws.com';
public String method = 'POST';
public string key;
public string secret;
public AWS_SES()
{
//Get key and secret from custom setting AWS__c
AWS__c objKeyDetails = [ Select SecretKey__c, AccessKey__c, Name From AWS__c ] ;
this.key = objKeyDetails.AccessKey__c;
this.secret = objKeyDetails.SecretKey__c;
}
public void sendEmail(List<String> toAddresses, String fromAddress, String subject, String body)
{
//Creating the instance of AWS_EmailFormat class
AWS_EmailFormat emailUtil = new AWS_EmailFormat();
//body of that method AWS_EmailDateFormat is defined in AWS_EmailFormat class.
String AWSEmailDateFormat = emailUtil.AWS_EmailDateFormat(Datetime.now());
HttpRequest httpReq = new HttpRequest();
httpReq.setEndpoint(endpoint);
httpReq.setMethod(method);
//body of that headerForAmazonAuthorization is defined in AWS_EmailFormat class.
httpReq.setHeader('X-Amzn-Authorization', emailUtil.headerForAmazonAuthorization(this.key, emailUtil.signature(AWSEmailDateFormat, this.secret)));
httpReq.setHeader('Content-Type', 'application/x-www-form-urlencoded');
httpReq.setHeader('Date', AWSEmailDateFormat);
emailUtil.emailSend(toAddresses, fromAddress, subject, body);
httpReq.setBody(emailUtil.encodeEmail());
System.debug('*******BODY*******'+httpReq.getBody());
Http http = new Http();
HttpResponse response = http.send(httpReq);
System.debug('RESPONSE FROM AWS'+response.getBody());
system.debug('OKAY THATS FINE THANKS!!!');
By using that code I am able to send email to AWS from salesforce and also I have got the response from AWS. Now I want to add attachment with the email and want to send request to AWS.
How can it be possible. Please give me the suggestion