Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL lcMessageId
LOCAL loPath
LOCAL lcRegion
LOCAL loHost
LOCAL loSigner
LOCAL loConnection
LOCAL loRest
LOCAL lcSessionToken
LOCAL lcResponseText
LOCAL loResponse
LOCAL i
LOCAL lnRecipients
LOCAL j
LOCAL lnCount
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
lnSuccess = 0
lcMessageId = "YOUR_SES_MESSAGE_ID"
loPath = CreateObject('Chilkat.StringBuilder')
loPath.Append("/v2/email/insights/")
loPath.Append(lcMessageId)
loPath.Append("/")
* Use the same AWS Region for the identity, endpoint, and Signature Version 4.
lcRegion = "us-west-2"
loHost = CreateObject('Chilkat.StringBuilder')
loHost.Append("email.")
loHost.Append(lcRegion)
loHost.Append(".amazonaws.com")
loSigner = CreateObject('Chilkat.AuthAws')
* Supply the credentials from your application's credential provider.
loSigner.AccessKey = "AWS_ACCESS_KEY_ID"
loSigner.SecretKey = "AWS_SECRET_ACCESS_KEY"
loSigner.Region = lcRegion
loSigner.ServiceName = "ses"
loConnection = CreateObject('Chilkat.Socket')
loConnection.RequireSslCertVerify = 1
lnSuccess = loConnection.Connect(loHost.GetAsString(),443,1,10000)
IF (lnSuccess <> 1) THEN
? loConnection.LastErrorText
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
CANCEL
ENDIF
loRest = CreateObject('Chilkat.Rest')
lnSuccess = loRest.UseConnection(loConnection,0)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
RELEASE loRest
CANCEL
ENDIF
lnSuccess = loRest.SetAuthAws(loSigner)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
RELEASE loRest
CANCEL
ENDIF
* For temporary AWS credentials, supply the session token from the same provider.
lcSessionToken = ""
IF (lcSessionToken <> "") THEN
loRest.AddQueryParam("X-Amz-Security-Token",lcSessionToken)
ENDIF
lcResponseText = loRest.FullRequestNoBody("GET",loPath.GetAsString())
IF (loRest.LastMethodSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
RELEASE loRest
CANCEL
ENDIF
IF (loRest.ResponseStatusCode = 404) THEN
? "No insights found. Check the Region, message ID, and VDM coverage."
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
RELEASE loRest
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "SES returned HTTP " + STR(loRest.ResponseStatusCode) + " " + lcResponseText
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
RELEASE loRest
CANCEL
ENDIF
loResponse = CreateObject('Chilkat.JsonObject')
lnSuccess = loResponse.Load(lcResponseText)
IF (lnSuccess <> 1) THEN
? loResponse.LastErrorText
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
RELEASE loRest
RELEASE loResponse
CANCEL
ENDIF
i = 0
lnRecipients = loResponse.SizeOfArray("Insights")
IF (lnRecipients < 1) THEN
? "No recipient history is available yet."
ENDIF
DO WHILE (i < lnRecipients)
loResponse.I = i
? loResponse.StringOf("Insights[i].Destination")
j = 0
lnCount = loResponse.SizeOfArray("Insights[i].Events")
DO WHILE (j < lnCount)
loResponse.J = j
? loResponse.StringOf("Insights[i].Events[j].Timestamp") + " " + loResponse.StringOf("Insights[i].Events[j].Type")
IF (loResponse.HasMember("Insights[i].Events[j].Details.Bounce.DiagnosticCode") = 1) THEN
? loResponse.StringOf("Insights[i].Events[j].Details.Bounce.DiagnosticCode")
ENDIF
IF (loResponse.HasMember("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType") = 1) THEN
? loResponse.StringOf("Insights[i].Events[j].Details.Complaint.ComplaintFeedbackType")
ENDIF
j = j + 1
ENDDO
i = i + 1
ENDDO
RELEASE loPath
RELEASE loHost
RELEASE loSigner
RELEASE loConnection
RELEASE loRest
RELEASE loResponse