SendGrid: Campaign, Send
Sends an email according to you Campaign settings in SendGrid.
Configs
- C1: Authorization Setting in which API Token is set *
- C2: Campaign ID *#{EL}
Script (click to open)
sendCampaign();
function sendCampaign(){
const auth = configs.get("conf_auth");
const url = createRequestUrl();
const response = httpClient.begin()
.authSetting(auth)
.post(url);
const httpStatus = response.getStatusCode();
engine.log("HTTP Status: " + String(httpStatus));
if(httpStatus >= 400){
const responseJson = JSON.parse(response.getResponseAsString());
let errorMessage = "";
for(let i = 0 ; i < responseJson.errors.length ; i++){
errorMessage = responseJson.errors[i].message + "\n";
}
throw errorMessage;
}
}
function createRequestUrl(){
const campaignId = configs.get("conf_campaign_id");
const requestUrl = "https://api.sendgrid.com/v3/campaigns/" + campaignId +"/schedules/now";
return requestUrl;
}
Download
2021-09-12 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/sendgrid-campaign-send/
The Add-on import feature is available with Professional edition.
Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.
Notes
- In the HTTP Authorization Settings of the workflow App in which this Add-on is to be used, add the API Key that you created in SendGrid under Settings > API Keys.
Capture
Like this:
Like Loading...
Related