AutoIt
AutoIt
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 AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$bSuccess = False
Local $sMessageId = "YOUR_SES_MESSAGE_ID"
$oPath = ObjCreate("Chilkat.StringBuilder")
$oPath.Append("/v2/email/insights/")
$oPath.Append($sMessageId)
$oPath.Append("/")
; Use the same AWS Region for the identity, endpoint, and Signature Version 4.
Local $sRegion = "us-west-2"
$oHost = ObjCreate("Chilkat.StringBuilder")
$oHost.Append("email.")
$oHost.Append($sRegion)
$oHost.Append(".amazonaws.com")
$oSigner = ObjCreate("Chilkat.AuthAws")
; Supply the credentials from your application's credential provider.
$oSigner.AccessKey = "AWS_ACCESS_KEY_ID"
$oSigner.SecretKey = "AWS_SECRET_ACCESS_KEY"
$oSigner.Region = $sRegion
$oSigner.ServiceName = "ses"
$oConnection = ObjCreate("Chilkat.Socket")
$oConnection.RequireSslCertVerify = True
$bSuccess = $oConnection.Connect($oHost.GetAsString(),443,True,10000)
If ($bSuccess <> True) Then
ConsoleWrite($oConnection.LastErrorText & @CRLF)
Exit
EndIf
$oRest = ObjCreate("Chilkat.Rest")
$bSuccess = $oRest.UseConnection($oConnection,False)
If ($bSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oRest.SetAuthAws($oSigner)
If ($bSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
; For temporary AWS credentials, supply the session token from the same provider.
Local $sessionToken = ""
If ($sessionToken <> "") Then
$oRest.AddQueryParam("X-Amz-Security-Token",$sessionToken)
EndIf
Local $sResponseText = $oRest.FullRequestNoBody("GET",$oPath.GetAsString())
If ($oRest.LastMethodSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
If ($oRest.ResponseStatusCode = 404) Then
ConsoleWrite("No insights found. Check the Region, message ID, and VDM coverage." & @CRLF)
Exit
EndIf
If ($oRest.ResponseStatusCode <> 200) Then
ConsoleWrite("SES returned HTTP " & $oRest.ResponseStatusCode & " " & $sResponseText & @CRLF)
Exit
EndIf
$oResponse = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oResponse.Load($sResponseText)
If ($bSuccess <> True) Then
ConsoleWrite($oResponse.LastErrorText & @CRLF)
Exit
EndIf
Local $i = 0
Local $iRecipients = $oResponse.SizeOfArray("Insights")
If ($iRecipients < 1) Then
ConsoleWrite("No recipient history is available yet." & @CRLF)
EndIf
While ($i < $iRecipients)
$oResponse.I = $i
ConsoleWrite($oResponse.StringOf("Insights[i].Destination") & @CRLF)
Local $iJ = 0
Local $iCount = $oResponse.SizeOfArray("Insights[i].Events")
While ($iJ < $iCount)
$oResponse.J = $iJ
ConsoleWrite($oResponse.StringOf("Insights[i].Events[j].Timestamp") & " " & $oResponse.StringOf("Insights[i].Events[j].Type") & @CRLF)
If ($oResponse.HasMember("Insights[i].Events[j].Details.Bounce.DiagnosticCode") = True) Then
ConsoleWrite($oResponse.StringOf("Insights[i].Events[j].Details.Bounce.DiagnosticCode") & @CRLF)
EndIf
If ($oResponse.HasMember("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType") = True) Then
ConsoleWrite($oResponse.StringOf("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType") & @CRLF)
EndIf
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend