AutoIt Requires Chilkat v11.0.0+
AutoIt
Constant Contact V3: Send a test email to reviewers
See more Constant Contact Examples
Read the primary activity ID from newsletter-selection.json. Replace the two reviewer addresses and send a preview with a personal note. Only the specified reviewers receive it. The request leaves the campaign schedule and contact lists alone.
Use up to five addresses per request. Each recipient counts toward the 50 daily test emails. Contact personalization and custom field values are not expanded in test messages. Success is HTTP 204 with an empty body.
Authorize the application using the same account and credential store.
Constant Contact developer guide
Chilkat AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$oVault = ObjCreate("Chilkat.Secrets")
$oVault.Location = "local_manager"
$oVault.AutoSplit = True
$oEntry = ObjCreate("Chilkat.JsonObject")
$oEntry.UpdateString("appName","ConstantContactV3")
$oEntry.UpdateString("service","OAuth2")
$oEntry.UpdateString("username","my-account")
$oTokens = ObjCreate("Chilkat.JsonObject")
Local $bLoaded = $oVault.GetSecretJson($oEntry,$oTokens)
If ($bLoaded <> True) Then
ConsoleWrite("Run the desktop authorization example using this account and store." & @CRLF)
Exit
EndIf
If ($oTokens.JsonTypeOf("access_token") <> 1) Then
ConsoleWrite("The saved authorization has no access token." & @CRLF)
Exit
EndIf
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True
$oHttp.AuthToken = $oTokens.StringOf("access_token")
$oResp = ObjCreate("Chilkat.HttpResponse")
; Use the selection file from the draft or campaign lookup example for this account.
$oSelection = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oSelection.LoadFile("newsletter-selection.json")
Local $sActivityId = $oSelection.StringOf("campaign_activity_id")
If (($bSuccess <> True) Or ($sActivityId = "")) Then
ConsoleWrite("Select a campaign and save its primary activity ID first." & @CRLF)
Exit
EndIf
$oHttp.SetUrlVar("activity",$sActivityId)
$oTestMail = ObjCreate("Chilkat.JsonObject")
$oTestMail.UpdateString("email_addresses[0]","editor@example.com")
$oTestMail.UpdateString("email_addresses[1]","reviewer@example.com")
$oTestMail.UpdateString("personal_message","Please check the workshop dates and the registration link.")
$bSuccess = $oHttp.HttpJson("POST","https://api.cc.email/v3/emails/activities/{$activity}/tests",$oTestMail,"application/json",$oResp)
If ($oResp.StatusCode = 429) Then
ConsoleWrite("HTTP 429: Test-send limit reached. Each reviewer counts toward the daily allowance." & @CRLF)
Exit
EndIf
If (($bSuccess <> True) And ($oResp.StatusCode <= 0)) Then
ConsoleWrite("Send reviewer test: HTTP request failed." & @CRLF)
Exit
EndIf
If (($bSuccess <> True) Or ($oResp.StatusCode <> 204)) Then
ConsoleWrite("Send reviewer test: HTTP " & $oResp.StatusCode & " " & $oResp.BodyStr & @CRLF)
Exit
EndIf
ConsoleWrite("Test email accepted for the two reviewer addresses." & @CRLF)