Xojo Plugin
Xojo Plugin
Amazon SES v2: Look up delivery history for a message ID
See more Amazon SES Examples
Enable Virtual Deliverability Manager for the sending account. Use the SES MessageId from a recent eligible send to a real test mailbox in the same Region. Mailbox simulator sends are excluded from VDM. Events are grouped by destination. Timestamps in the REST response are Unix epoch seconds.
GetMessageInsights · VDM dashboard
Chilkat Xojo Plugin Downloads
Dim success As Boolean
success = False
// Assumes Chilkat is unlocked. See Global Unlock Sample.
success = False
Dim messageId As String
messageId = "YOUR_SES_MESSAGE_ID"
Dim path As New Chilkat.StringBuilder
success = path.Append("/v2/email/insights/")
success = path.Append(messageId)
success = path.Append("/")
// 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 Chilkat.StringBuilder
success = host.Append("email.")
success = host.Append(region)
success = host.Append(".amazonaws.com")
Dim signer As New 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"
Dim connection As New Chilkat.Socket
connection.RequireSslCertVerify = True
success = connection.Connect(host.GetAsString(),443,True,10000)
If (success <> True) Then
System.DebugLog(connection.LastErrorText)
Return
End If
Dim rest As New Chilkat.Rest
success = rest.UseConnection(connection,False)
If (success <> True) Then
System.DebugLog(rest.LastErrorText)
Return
End If
success = rest.SetAuthAws(signer)
If (success <> True) Then
System.DebugLog(rest.LastErrorText)
Return
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
Dim responseText As String
responseText = rest.FullRequestNoBody("GET",path.GetAsString())
If (rest.LastMethodSuccess <> True) Then
System.DebugLog(rest.LastErrorText)
Return
End If
If (rest.ResponseStatusCode = 404) Then
System.DebugLog("No insights found. Check the Region, message ID, and VDM coverage.")
Return
End If
If (rest.ResponseStatusCode <> 200) Then
System.DebugLog("SES returned HTTP " + Str(rest.ResponseStatusCode) + " " + responseText)
Return
End If
Dim response As New Chilkat.JsonObject
success = response.Load(responseText)
If (success <> True) Then
System.DebugLog(response.LastErrorText)
Return
End If
Dim i As Int32
i = 0
Dim recipients As Int32
recipients = response.SizeOfArray("Insights")
If (recipients < 1) Then
System.DebugLog("No recipient history is available yet.")
End If
While (i < recipients)
response.I = i
System.DebugLog(response.StringOf("Insights[i].Destination"))
Dim j As Int32
j = 0
Dim count As Int32
count = response.SizeOfArray("Insights[i].Events")
While (j < count)
response.J = j
System.DebugLog(response.StringOf("Insights[i].Events[j].Timestamp") + " " + response.StringOf("Insights[i].Events[j].Type"))
If (response.HasMember("Insights[i].Events[j].Details.Bounce.DiagnosticCode") = True) Then
System.DebugLog(response.StringOf("Insights[i].Events[j].Details.Bounce.DiagnosticCode"))
End If
If (response.HasMember("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType") = True) Then
System.DebugLog(response.StringOf("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType"))
End If
j = j + 1
Wend
i = i + 1
Wend