AutoIt
AutoIt
Amazon SES v2: Send a plain text email
See more Amazon SES Examples
Send a plain text confirmation using a verified sender and credentials with ses:SendEmail. The SES mailbox simulator also works in the sandbox. Other sandbox recipients must be verified. SES permits up to 50 recipients total across To, CC and BCC. Save the returned message ID to correlate later delivery events.
SendEmail · SES sandbox · Sending quotas
Chilkat AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$bSuccess = False
; Replace the From address with your verified sender. The destination is the SES mailbox simulator.
$oRequest = ObjCreate("Chilkat.JsonObject")
$oRequest.UpdateString("FromEmailAddress","sender+reports@example.com")
$oRequest.UpdateString("Destination.ToAddresses[0]","success@simulator.amazonses.com")
$oRequest.UpdateString("Content.Simple.Subject.Data","Report ready")
$oRequest.UpdateString("Content.Simple.Subject.Charset","UTF-8")
$oRequest.UpdateString("Content.Simple.Body.Text.Data","Your weekly report is ready to view.")
$oRequest.UpdateString("Content.Simple.Body.Text.Charset","UTF-8")
; 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
$oRest.AddHeader("Content-Type","application/json")
Local $sResponseText = $oRest.FullRequestString("POST","/v2/email/outbound-emails",$oRequest.Emit())
If ($oRest.LastMethodSuccess <> True) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
If ($oRest.ResponseStatusCode <> 200) Then
ConsoleWrite("SES returned HTTP " & $oRest.ResponseStatusCode & " " & $sResponseText & @CRLF)
Exit
EndIf
$oResult = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oResult.Load($sResponseText)
If ($bSuccess <> True) Then
ConsoleWrite($oResult.LastErrorText & @CRLF)
Exit
EndIf
If ($oResult.HasMember("MessageId") <> True) Then
ConsoleWrite("SES returned no message ID." & @CRLF)
Exit
EndIf
ConsoleWrite("SES accepted the message. Message ID: " & $oResult.StringOf("MessageId") & @CRLF)