My Code.gs
file in my apps script project has this code (given below) whose task is to send an email using AWS SES Javascript SDK. -
function doGet() {
var self=globalThis;
var url = "https://sdk.amazonaws.com/js/aws-sdk-2.1206.0.min.js";
eval(UrlFetchApp.fetch(url).getContentText());
const data1 = "sample@gmail.com | John Doe";
const data = data1.split(" | ");
const email = data[0];
const name = data[1];
const configure = {
accessKeyId: "<mykeyid>",
secretAccessKey: "<mykeysecret>",
apiVersion: '2010-12-01',
region: 'us-east-1'
};
const ses = new AWS.SES(configure);
const parameters = {
Destination:{
ToAddresses:[
email
]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: `<!DOCTYPE html><html>Hi, ` + name + `!</html>`
}
},
Subject: {
Charset: "UTF-8",
Data: "Here's a sample email."
}
},
Source: 'Sample Sender <example@gmail.com>'
}
ses.sendEmail(parameters,(err,data)=>{
if(err) {
document.write(err);
} else {
document.write("Done");
}
});
}
When I run the doGet()
function, it shows me this error -
Why did this error show up and what should I do? Also I don't have any other code except this one. I searched for this error, and I found out that setTimeout is not defined
error comes when there is some typo/mistake in using it - but my code doesn't seem to have any setTimeout function - what could be wrong? I've just started with JS & google apps script, hence I am a bit confused... Kindly advice... Thanks! :)
P.S. The whole AWS code works properly when tested in a proper JS file externally.