Last active
July 9, 2020 20:36
-
-
Save guikaercher/47d1ddc7b8635edd9868aa2b9e79e6af to your computer and use it in GitHub Desktop.
AWS SES endpoints for TEMPLATES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk'); | |
const ses = new AWS.SES({ | |
region: 'us-east-1' | |
}); | |
const createTemplate = () => { | |
var params = { | |
Template: { /* required */ | |
TemplateName: 'teste_template', /* required */ | |
HtmlPart: 'teste html', | |
SubjectPart: 'teste subject', | |
TextPart: 'teste text' | |
} | |
}; | |
ses.createTemplate(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
} | |
const updateTemplate = () => { | |
var params = { | |
Template: { /* required */ | |
TemplateName: 'teste_template', /* required */ | |
HtmlPart: 'html atualizado', | |
SubjectPart: 'teste subject atualizado', | |
TextPart: 'teste text atualizado' | |
} | |
}; | |
ses.updateTemplate(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
} | |
const getTemplate = () => { | |
var params = { | |
TemplateName: 'teste_template' /* required */ | |
}; | |
ses.getTemplate(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
} | |
const listTemplates = () => { | |
var params = { | |
MaxItems: 0, | |
// NextToken: '' | |
}; | |
ses.listTemplates(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
} | |
const ReplacementTemplateData = {name: "Guilherme", favoriteanimal: "angelfish" } | |
const DefaultTemplateData = { name: "friend", favoriteanimal : "unknown" } | |
var params = { | |
Source:"[email protected]", | |
Template:"template_with_variables", | |
ConfigurationSetName: "", | |
Destinations:[ | |
{ | |
Destination:{ | |
ToAddresses:[ | |
"[email protected]" | |
] | |
}, | |
ReplacementTemplateData: JSON.stringify(ReplacementTemplateData) | |
} | |
], | |
DefaultTemplateData: JSON.stringify(DefaultTemplateData) | |
} | |
ses.sendBulkTemplatedEmail(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment