Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.0.0+

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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
set vault = Server.CreateObject("Chilkat.Secrets")
vault.Location = "local_manager"
vault.AutoSplit = 1
set entry = Server.CreateObject("Chilkat.JsonObject")
success = entry.UpdateString("appName","ConstantContactV3")
success = entry.UpdateString("service","OAuth2")
success = entry.UpdateString("username","my-account")
set tokens = Server.CreateObject("Chilkat.JsonObject")
loaded = vault.GetSecretJson(entry,tokens)
If (loaded <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Run the desktop authorization example using this account and store.") & "</pre>"
    Response.End
End If

If (tokens.JsonTypeOf("access_token") <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "The saved authorization has no access token.") & "</pre>"
    Response.End
End If

set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
http.AuthToken = tokens.StringOf("access_token")
set resp = Server.CreateObject("Chilkat.HttpResponse")

'  Use the selection file from the draft or campaign lookup example for this account.
set selection = Server.CreateObject("Chilkat.JsonObject")
success = selection.LoadFile("newsletter-selection.json")
activityId = selection.StringOf("campaign_activity_id")
If ((success <> 1) Or (activityId = "")) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Select a campaign and save its primary activity ID first.") & "</pre>"
    Response.End
End If

success = http.SetUrlVar("activity",activityId)
set testMail = Server.CreateObject("Chilkat.JsonObject")
success = testMail.UpdateString("email_addresses[0]","editor@example.com")
success = testMail.UpdateString("email_addresses[1]","reviewer@example.com")
success = testMail.UpdateString("personal_message","Please check the workshop dates and the registration link.")
success = http.HttpJson("POST","https://api.cc.email/v3/emails/activities/{$activity}/tests",testMail,"application/json",resp)
If (resp.StatusCode = 429) Then
    Response.Write "<pre>" & Server.HTMLEncode( "HTTP 429: Test-send limit reached. Each reviewer counts toward the daily allowance.") & "</pre>"
    Response.End
End If

If ((success <> 1) And (resp.StatusCode <= 0)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Send reviewer test: HTTP request failed.") & "</pre>"
    Response.End
End If

If ((success <> 1) Or (resp.StatusCode <> 204)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Send reviewer test: HTTP " & resp.StatusCode & " " & resp.BodyStr) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Test email accepted for the two reviewer addresses.") & "</pre>"

%>
</body>
</html>