title: How do I correctly use the SendBulkTemplatedEmailRequest from SES in the AWS-SDK-NET?
body: <p>I am attempting to use the <strong>AmazonSimpleEmailService</strong> client via the <strong>AWS-SDK for .Net</strong>, to send a <strong>SendBulkTempatedEmailRequest</strong>. I have implemented a dedicated handler for actually building the request and making the <strong>SendBulkTemplatedEmailAsync</strong> call. It is not working as I expect. I think there is a bug with how the request object is serialized and passed to the API.</p>
  
  <p>Here is some sample code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Amazon.SimpleEmail;
  using Amazon.SimpleEmail.Model;
  using Newtonsoft.Json;
  
  namespace Sample.AWS.SES
  {
    public class SendEmailService
    {   
      private readonly IAmazonSimpleEmailService _sesClient;
  
      public SendEmailService(IAmazonSimpleEmailService sesClient)
      {
        _sesClient = sesClient;
      }
  
      public async Task&lt;string&gt; SendBulkEmailAsync(SesOrderCreatedBulkTemplate data)
      {
        var result = string.Empty;
        var request = new SendBulkTemplatedEmailRequest
        {
          Template = data.Template,
          ConfigurationSetName = data.ConfigurationSet,
          DefaultTemplateData = JsonConvert.SerializeObject(data.DefaultTemplateData),
          Source = data.Source,
          Destinations = data.Destinations
            .Select(d =&gt; new BulkEmailDestination
            {
              Destination = new Destination
              {
                ToAddresses = d.ToAddresses.ToList(),
              },
              ReplacementTemplateData = string.Empty
            })
            .ToList(),
          ReplyToAddresses = data.ReplyToAddresses.ToList()
        };
  
        try
        {
          var resp = await _sesClient.SendBulkTemplatedEmailAsync(request);
        }
        catch (Exception ex)
        {
          var msgEx = new Exception("Error sending message to SES.", ex);
          throw msgEx;
        }
        return result;
      }
  
      public class SesOrderCreatedBulkTemplate
      {
        public string Source { get; set; }
        public string Template { get; set; }
        public string ConfigurationSet { get; set; }
        public IEnumerable&lt;Destination&gt; Destinations { get; set; }
        public MyTemplateData DefaultTemplateData { get; set; }
        public IEnumerable&lt;string&gt; ReplyToAddresses { get; set; }
        public string ReturnPath { get; set; } = string.Empty;
      }
  
      public class DestinationObj
      {
        public IEnumerable&lt;string&gt; ToAddresses { get; set; }
        public MyTemplateData ReplacementTemplateData { get; set; }
  
        public DestinationObj() {}
      }
  
      public class MyTemplateData
      {
        public List&lt;Person&gt; Tenants { get; set; }
      }
  
      public class Person
      {
        public string PersonName { get; set; }
        public List&lt;object&gt; PersonData { get; set; }
      }
    }
  }
  </code></pre>
  
  <p>The properties for <code>SourceArn</code>, <code>TemplateArn</code> and <code>ReturnPathArn</code> are omitted on purpose.  According the <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/using-the-api.html" rel="nofollow noreferrer">SES documentation</a>, the SDK wraps the low-level functionality of the Amazon SES API with higher-level data types and function calls that take care of the details for you. When I view the <a href="https://docs.aws.amazon.com/ses/latest/APIReference/API_SendBulkTemplatedEmail.html" rel="nofollow noreferrer">API documentation for sending bulk email</a>, the ARN properties are all list as <strong>not required</strong>. When I look at the some <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-personalized-email-api.html" rel="nofollow noreferrer">CLI examples</a>, it is the same. When I look at the documentation for the <a href="https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/SimpleEmail/TSendBulkTemplatedEmailRequest.html" rel="nofollow noreferrer">SDK for .Net v3</a>, it is ambiguous (not marked as required or optional).</p>
  
  <p>Because the SDK supposed to wrap the low-level functionality of the API, I do not believe the ARN values are required (neither the API nor the CLI require them). However, when I attempt to actually use the request object created in the code snippet, I get an error that says <code>InvalidTemplateData</code>.</p>
  
  <p><strong><em>If I serialize the request object to JSON, then remove the 3 ARN fields from the string, I can use either the API or the CLI to successfully send the message.</em></strong> </p>
  
  <p>In addition to not specifying a value for the ARN's, I have tried (for all 3 ARN values):</p>
  
  <p><code>specificArn = string.empty;</code>
  <code>specificArn = new {};</code>
  <code>specificArn = "";</code></p>
  
  <p>I have also tried explicitly newing-up the object separate from initializing the properties:<br>
  <code>var request = new SendBulkTemplatedEmailRequest();</code>, and then individually populating the properties.</p>
  
  <p>If I don't initialize the ARN values, I get an error about <strong>NoneType</strong> vs <strong>StringType</strong> when the send method is called. The variations on string initialization that I tried result in <strong>InvalidTemplateData</strong> errors.</p>
  
  <p>Note, I do know ARN values for Source and ReturnPath. I do not have an ARN value for the template we use. Supposedly, using the CLI, when you create a template you should receive a response back that includes the ARN for the template. I get no response from the CLI when I create a template, but it does get created every time I try. The <code>describe-template</code> CLI command is not valid when you specify SES and responds with an error if I don't specify the workspace (whatever you call the SES space) value.</p>
  
  <p>Does anyone have a suggestion on how to solve this?</p>