VB.NET
VB.NET
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 VB.NET Downloads
Dim success As Boolean = False
' Assumes Chilkat is unlocked. See Global Unlock Sample.
success = False
Dim messageId As String = "YOUR_SES_MESSAGE_ID"
Dim path As New Chilkat.StringBuilder
path.Append("/v2/email/insights/")
path.Append(messageId)
path.Append("/")
' Use the same AWS Region for the identity, endpoint, and Signature Version 4.
Dim region As String = "us-west-2"
Dim host As New Chilkat.StringBuilder
host.Append("email.")
host.Append(region)
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
Debug.WriteLine(connection.LastErrorText)
Exit Sub
End If
Dim rest As New Chilkat.Rest
success = rest.UseConnection(connection,False)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
success = rest.SetAuthAws(signer)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
' For temporary AWS credentials, supply the session token from the same provider.
Dim sessionToken As String = ""
If (sessionToken <> "") Then
rest.AddQueryParam("X-Amz-Security-Token",sessionToken)
End If
Dim responseText As String = rest.FullRequestNoBody("GET",path.GetAsString())
If (rest.LastMethodSuccess <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
If (rest.ResponseStatusCode = 404) Then
Debug.WriteLine("No insights found. Check the Region, message ID, and VDM coverage.")
Exit Sub
End If
If (rest.ResponseStatusCode <> 200) Then
Debug.WriteLine("SES returned HTTP " & rest.ResponseStatusCode & " " & responseText)
Exit Sub
End If
Dim response As New Chilkat.JsonObject
success = response.Load(responseText)
If (success <> True) Then
Debug.WriteLine(response.LastErrorText)
Exit Sub
End If
Dim i As Integer = 0
Dim recipients As Integer = response.SizeOfArray("Insights")
If (recipients < 1) Then
Debug.WriteLine("No recipient history is available yet.")
End If
While (i < recipients)
response.I = i
Debug.WriteLine(response.StringOf("Insights[i].Destination"))
Dim j As Integer = 0
Dim count As Integer = response.SizeOfArray("Insights[i].Events")
While (j < count)
response.J = j
Debug.WriteLine(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
Debug.WriteLine(response.StringOf("Insights[i].Events[j].Details.Bounce.DiagnosticCode"))
End If
If (response.HasMember("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType") = True) Then
Debug.WriteLine(response.StringOf("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType"))
End If
j = j + 1
End While
i = i + 1
End While