Sample code for 30+ languages & platforms
Classic ASP

Amazon SES v2: Send private appointment reminders and inspect each result

See more Amazon SES Examples

Replace the two recipients with test mailboxes you control. The example supplies an inline template and one private destination per entry. Store each successful message ID against its appointment. Schedule a retry with backoff only for entries with a retryable outcome. Correct permanent errors before resubmission.

SendBulkEmail · Per-entry outcomes

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
success = 0

ERROR: ASP example cannot use request or response as a variable name.
success = request.UpdateString("FromEmailAddress","sender@example.com")
success = request.UpdateString("DefaultContent.Template.TemplateContent.Subject","Appointment reminder")
success = request.UpdateString("DefaultContent.Template.TemplateContent.Text","Hello {{name}}, your appointment is {{slot}}.")
success = request.UpdateString("DefaultContent.Template.TemplateData","{""name"":""there"",""slot"":""in your booking confirmation""}")

set firstReminder = Server.CreateObject("Chilkat.JsonObject")
success = firstReminder.UpdateString("name","Avery")
success = firstReminder.UpdateString("slot","Tuesday at 9 AM Central")
success = request.UpdateString("BulkEmailEntries[0].Destination.ToAddresses[0]","avery@example.com")
success = request.UpdateString("BulkEmailEntries[0].ReplacementEmailContent.ReplacementTemplate.ReplacementTemplateData",firstReminder.Emit())

set secondReminder = Server.CreateObject("Chilkat.JsonObject")
success = secondReminder.UpdateString("name","Robin")
success = secondReminder.UpdateString("slot","Wednesday at 2 PM Central")
success = request.UpdateString("BulkEmailEntries[1].Destination.ToAddresses[0]","robin@example.com")
success = request.UpdateString("BulkEmailEntries[1].ReplacementEmailContent.ReplacementTemplate.ReplacementTemplateData",secondReminder.Emit())
'  Use the same AWS Region for the identity, endpoint, and Signature Version 4.
region = "us-west-2"
set host = Server.CreateObject("Chilkat.StringBuilder")
success = host.Append("email.")
success = host.Append(region)
success = host.Append(".amazonaws.com")

set signer = Server.CreateObject("Chilkat.AuthAws")
'  Supply the credentials from your application's credential provider.
signer.AccessKey = "AWS_ACCESS_KEY_ID"
signer.SecretKey = "AWS_SECRET_ACCESS_KEY"
signer.Region = region
signer.ServiceName = "ses"

set connection = Server.CreateObject("Chilkat.Socket")
connection.RequireSslCertVerify = 1
success = connection.Connect(host.GetAsString(),443,1,10000)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( connection.LastErrorText) & "</pre>"
    Response.End
End If

set rest = Server.CreateObject("Chilkat.Rest")
success = rest.UseConnection(connection,0)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

success = rest.SetAuthAws(signer)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

'  For temporary AWS credentials, supply the session token from the same provider.
sessionToken = ""
If (sessionToken <> "") Then
    success = rest.AddQueryParam("X-Amz-Security-Token",sessionToken)
End If

success = rest.AddHeader("Content-Type","application/json")
responseText = rest.FullRequestString("POST","/v2/email/outbound-bulk-emails",request.Emit())
If (rest.LastMethodSuccess <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

If (rest.ResponseStatusCode <> 200) Then
    Response.Write "<pre>" & Server.HTMLEncode( "SES returned HTTP " & rest.ResponseStatusCode & " " & responseText) & "</pre>"
    Response.End
End If

ERROR: ASP example cannot use request or response as a variable name.
success = response.Load(responseText)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( response.LastErrorText) & "</pre>"
    Response.End
End If

count = response.SizeOfArray("BulkEmailEntryResults")
If (count <> request.SizeOfArray("BulkEmailEntries")) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Incomplete results. Reconcile the original batch before retrying.") & "</pre>"
    Response.End
End If

i = 0
Do While (i < count)
ERROR: ASP example cannot use request or response as a variable name.
ERROR: ASP example cannot use request or response as a variable name.
    recipient = request.StringOf("BulkEmailEntries[i].Destination.ToAddresses[0]")
    status = response.StringOf("BulkEmailEntryResults[i].Status")
    If (status = "SUCCESS") Then
        Response.Write "<pre>" & Server.HTMLEncode( recipient & " accepted: " & response.StringOf("BulkEmailEntryResults[i].MessageId")) & "</pre>"
    Else
        If ((status = "ACCOUNT_THROTTLED") Or (status = "TRANSIENT_FAILURE")) Then
            Response.Write "<pre>" & Server.HTMLEncode( recipient & " retry later: " & status) & "</pre>"
        Else
            Response.Write "<pre>" & Server.HTMLEncode( recipient & " review before retry: " & status & " " & response.StringOf("BulkEmailEntryResults[i].Error")) & "</pre>"
        End If

    End If

    i = i + 1
Loop

%>
</body>
</html>