Visual Basic 6.0 Requires Chilkat v11.0.0+
Visual Basic 6.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 Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim vault As New ChilkatSecrets
vault.Location = "local_manager"
vault.AutoSplit = 1
Dim entry As New ChilkatJsonObject
success = entry.UpdateString("appName","ConstantContactV3")
success = entry.UpdateString("service","OAuth2")
success = entry.UpdateString("username","my-account")
Dim tokens As New ChilkatJsonObject
Dim loaded As Long
loaded = vault.GetSecretJson(entry,tokens)
If (loaded <> 1) Then
Debug.Print "Run the desktop authorization example using this account and store."
Exit Sub
End If
If (tokens.JsonTypeOf("access_token") <> 1) Then
Debug.Print "The saved authorization has no access token."
Exit Sub
End If
Dim http As New ChilkatHttp
http.RequireSslCertVerify = 1
http.AuthToken = tokens.StringOf("access_token")
Dim resp As New ChilkatHttpResponse
' Use the selection file from the draft or campaign lookup example for this account.
Dim selection As New ChilkatJsonObject
success = selection.LoadFile("newsletter-selection.json")
Dim activityId As String
activityId = selection.StringOf("campaign_activity_id")
If ((success <> 1) Or (activityId = "")) Then
Debug.Print "Select a campaign and save its primary activity ID first."
Exit Sub
End If
success = http.SetUrlVar("activity",activityId)
Dim testMail As New ChilkatJsonObject
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
Debug.Print "HTTP 429: Test-send limit reached. Each reviewer counts toward the daily allowance."
Exit Sub
End If
If ((success <> 1) And (resp.StatusCode <= 0)) Then
Debug.Print "Send reviewer test: HTTP request failed."
Exit Sub
End If
If ((success <> 1) Or (resp.StatusCode <> 204)) Then
Debug.Print "Send reviewer test: HTTP " & resp.StatusCode & " " & resp.BodyStr
Exit Sub
End If
Debug.Print "Test email accepted for the two reviewer addresses."