Visual Basic 6.0
Visual Basic 6.0
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 Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
success = 0
Dim request As New ChilkatJsonObject
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""}")
Dim firstReminder As New ChilkatJsonObject
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())
Dim secondReminder As New ChilkatJsonObject
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.
Dim region As String
region = "us-west-2"
Dim host As New ChilkatStringBuilder
success = host.Append("email.")
success = host.Append(region)
success = host.Append(".amazonaws.com")
Dim signer As New ChilkatAuthAws
' 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"
Dim connection As New ChilkatSocket
connection.RequireSslCertVerify = 1
success = connection.Connect(host.GetAsString(),443,1,10000)
If (success <> 1) Then
Debug.Print connection.LastErrorText
Exit Sub
End If
Dim rest As New ChilkatRest
success = rest.UseConnection(connection,0)
If (success <> 1) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
success = rest.SetAuthAws(signer)
If (success <> 1) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
' For temporary AWS credentials, supply the session token from the same provider.
Dim sessionToken As String
sessionToken = ""
If (sessionToken <> "") Then
success = rest.AddQueryParam("X-Amz-Security-Token",sessionToken)
End If
success = rest.AddHeader("Content-Type","application/json")
Dim responseText As String
responseText = rest.FullRequestString("POST","/v2/email/outbound-bulk-emails",request.Emit())
If (rest.LastMethodSuccess <> 1) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
If (rest.ResponseStatusCode <> 200) Then
Debug.Print "SES returned HTTP " & rest.ResponseStatusCode & " " & responseText
Exit Sub
End If
Dim response As New ChilkatJsonObject
success = response.Load(responseText)
If (success <> 1) Then
Debug.Print response.LastErrorText
Exit Sub
End If
Dim count As Long
count = response.SizeOfArray("BulkEmailEntryResults")
If (count <> request.SizeOfArray("BulkEmailEntries")) Then
Debug.Print "Incomplete results. Reconcile the original batch before retrying."
Exit Sub
End If
Dim i As Long
i = 0
Do While (i < count)
response.I = i
request.I = i
Dim recipient As String
recipient = request.StringOf("BulkEmailEntries[i].Destination.ToAddresses[0]")
Dim status As String
status = response.StringOf("BulkEmailEntryResults[i].Status")
If (status = "SUCCESS") Then
Debug.Print recipient & " accepted: " & response.StringOf("BulkEmailEntryResults[i].MessageId")
Else
If ((status = "ACCOUNT_THROTTLED") Or (status = "TRANSIENT_FAILURE")) Then
Debug.Print recipient & " retry later: " & status
Else
Debug.Print recipient & " review before retry: " & status & " " & response.StringOf("BulkEmailEntryResults[i].Error")
End If
End If
i = i + 1
Loop