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 = "[email protected] | 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 <[email protected]>'
}
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.

https://sdk.amazonaws.com/js/aws-sdk-2.1206.0.min.jsis for Javascript. In the case of Google Apps Scrtipt, unfortunately, not all functions of Javascript cannot be used. In the case of your question,setTimeoutcannot be used. And also,document.writecannot be used. Please be careful this. Ref1, Ref2, Ref3What do you mean by In the case of your question, setTimeout cannot be used - i am not using settimeout in my code, I think thatsetTimeoutis used in the script ofhttps://sdk.amazonaws.com/js/aws-sdk-2.1206.0.min.js. When you will check the script, I think that you can see it.What method should I use if I still want to use the aws js sdk in my apps script? or is it not doable?, in this case, I think that there might be 2 patterns. 1. Modify the script ofhttps://sdk.amazonaws.com/js/aws-sdk-2.1206.0.min.jsfor Google Apps Script. 2. Directly request to the endpoint of the API using Google Apps Script.In the second pattern, do you mean the AWS SES API?, if you want to send an email using Amazon SES API, I think that it's yes.do you know any introductory articles? and will I be able to integrate that rest api in google apps script?, although I'm not sure whether I could correctly understand your goal, is this document useful? docs.aws.amazon.com/ses/latest/dg/send-email-api.html