function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SidharthSidharth 

Integrating Salesforce with Amazon SES (Simple Email Service)

Hi Everyone

 

Has anybody integrated Amazon SES web Service with Salesforce. If yes, please guide me to the right direction.

 

Thanks

Sid

Best Answer chosen by Admin (Salesforce Developers) 
thomastthomast

I haven't tried it out yet, but there's an interesting blog post at Model Metrics that talks about using AWS's SES with Force.com.

 

All Answers

IspitaIspita

Hi,
The following Web link has some information on "Simple Email sErvice" of Amazon and the API's exposed by it for cloud based solutions:-

 

 

 

thomastthomast

I haven't tried it out yet, but there's an interesting blog post at Model Metrics that talks about using AWS's SES with Force.com.

 

This was selected as the best answer
SidharthSidharth

Heres a sample C# code for SES(for sending Email

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

using Amazon;
using Amazon.S3;
using Amazon.S3.Model;

namespace AWS_Console_App1
{
    class testSES
    {
        //public static void Main(string[] args)
        //{
        //    Console.Write(GetServiceOutput());
        //    Console.Read();
        //}
    
        public static void GetServiceOutput(String body1, String subject1, String Source1, String Destination1)
        {
            Console.WriteLine("==============E-Mail===========\n");

            Amazon.SimpleEmail.AmazonSimpleEmailServiceClient sesClient = (Amazon.SimpleEmail.AmazonSimpleEmailServiceClient)AWSClientFactory.CreateAmazonSimpleEmailServiceClient();
                
            Amazon.SimpleEmail.Model.Destination sesDestination = new Amazon.SimpleEmail.Model.Destination();
            sesDestination.ToAddresses.Add(Destination1);
            Amazon.SimpleEmail.Model.Content sesContent1 = new Amazon.SimpleEmail.Model.Content(body1);
            Amazon.SimpleEmail.Model.Content sesContent2 = new Amazon.SimpleEmail.Model.Content(subject1);
            Amazon.SimpleEmail.Model.Body sesBody = new Amazon.SimpleEmail.Model.Body(sesContent1);
            Amazon.SimpleEmail.Model.Message sesMessage = new Amazon.SimpleEmail.Model.Message();
            sesMessage.Body = sesBody;
            sesMessage.Subject = sesContent2;

            try
            {
                Amazon.SimpleEmail.Model.ListVerifiedEmailAddressesResponse sesResponse1 = sesClient.ListVerifiedEmailAddresses(new Amazon.SimpleEmail.Model.ListVerifiedEmailAddressesRequest());
                Console.WriteLine("One of the Verified Email Address : " + sesResponse1.ListVerifiedEmailAddressesResult.VerifiedEmailAddresses[0]);
                Console.WriteLine("Number of Verified Email Addresses : " + sesResponse1.ListVerifiedEmailAddressesResult.VerifiedEmailAddresses.Count());
                Amazon.SimpleEmail.Model.SendEmailResponse sesResponse2 = sesClient.SendEmail(new Amazon.SimpleEmail.Model.SendEmailRequest(Source1, sesDestination, sesMessage));

            }
            catch (AmazonS3Exception ex)
            {
                if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                    ex.ErrorCode.Equals("InvalidSecurity")))
                {
                    Console.WriteLine("Please check the provided AWS Credentials.");
                    Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                }
                else
                {
                    Console.WriteLine("Caught Exception: " + ex.Message);
                    Console.WriteLine("Response Status Code: " + ex.StatusCode);
                    Console.WriteLine("Error Code: " + ex.ErrorCode);
                    Console.WriteLine("Request ID: " + ex.RequestId);
                    Console.WriteLine("XML: " + ex.XML);
                }
            }
            Console.WriteLine("\n\nPress any key to SMS the information...\n");
            Console.ReadLine();

            Console.WriteLine("==============SMS===========\n");

            Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient snsClient = (Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient)AWSClientFactory.CreateAmazonSNSClient();
            try
            {
                Amazon.SimpleNotificationService.Model.ListTopicsResponse snsResponse1 = snsClient.ListTopics(new Amazon.SimpleNotificationService.Model.ListTopicsRequest());
                Amazon.SimpleNotificationService.Model.ListSubscriptionsResponse snsResponse2 = snsClient.ListSubscriptions(new Amazon.SimpleNotificationService.Model.ListSubscriptionsRequest());
                   

                string topicARN = "";

                if (snsResponse1.IsSetListTopicsResult())
                {
                    Amazon.SimpleNotificationService.Model.ListTopicsResult snsResult1 = snsResponse1.ListTopicsResult;
                    Console.WriteLine("List of Topics:\n");
                    foreach (Amazon.SimpleNotificationService.Model.Topic topic in snsResult1.Topics)
                    {
                        Console.WriteLine("  " + topic.TopicArn);
                        topicARN = topic.TopicArn.ToString();
                    }
                }

                if (snsResponse2.IsSetListSubscriptionsResult())
                {
                    Amazon.SimpleNotificationService.Model.ListSubscriptionsResult snsResult2 = snsResponse2.ListSubscriptionsResult;
                    Console.WriteLine("\nList of Subcriptions:\n");
                    foreach (Amazon.SimpleNotificationService.Model.Subscription subcription in snsResult2.Subscriptions)
                    {
                        Console.WriteLine("  " + subcription.TopicArn);
                        Console.WriteLine("  " + subcription.SubscriptionArn);
                    }        
                }

                Amazon.SimpleNotificationService.Model.PublishRequest snsRequest = new Amazon.SimpleNotificationService.Model.PublishRequest();
                snsRequest.Message = body1;   
                snsRequest.TopicArn = topicARN;

                Amazon.SimpleNotificationService.Model.PublishResponse snsResponse3 = snsClient.Publish(snsRequest);

                if (snsResponse3.IsSetPublishResult())
                {
                    Amazon.SimpleNotificationService.Model.PublishResult snsResult3 = snsResponse3.PublishResult;
                }


            }
            catch (Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceException ex)
            {
                if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                    ex.ErrorCode.Equals("InvalidSecurity")))
                {
                    Console.WriteLine("Please check the provided AWS Credentials.");
                    Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                }
                else
                {
                    Console.WriteLine("Caught Exception: " + ex.Message);
                    Console.WriteLine("Response Status Code: " + ex.StatusCode);
                    Console.WriteLine("Error Code: " + ex.ErrorCode);
                    Console.WriteLine("Request ID: " + ex.RequestId);
                    Console.WriteLine("XML: " + ex.XML);
                }
            }   

        }
    }
}

 

) and SNS(for sending SMS)

seahorcesolnsseahorcesolns

I've implemented AWS SES within some Apex code and it was working nicely.  In our org, emails are being generated via Apex code in sets of over 10 recipients at one time with unique recipient, cc, and body values.  This requires the code to pass Amazon SES the data for each email one at a time because the data is unique for each.  So when over 10 recipients are being selected, we are hitting the callout limit (Too many callouts: 11).

 

We tried using the @future method to get around the callout limit, but still received the following error:
Too many future calls: 11
Error is in expression '{!actionSendButton}' in component <apex:page> in page sendemail

 

Any suggestions on how to get around this?

 

 

fdsf fdsfdsfdsf fdsfds

Can I use this script in my tool and blog of amazong product guide? I want to show some related articles like finding high demand product for amazon, you can see the detail format here  (https://sageseller.com/blog/how-to-find-high-demand-products-to-sell-on-amazon/)
Omi SolutionsOmi Solutions

Hi seahorcesolns,

I am trying send emails from Apex by using AWS SES, can you help me for this. I am getting error like 403 Forbidden & Signature is expired.

Thanks in Advance