dxdc / aws-sdk-google-apps

Native Google Apps Script support for Amazon AWS SDK for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A little help to use AWS-SDK with google app script

Thomas3795 opened this issue · comments

Hi,

I found your component aws-sdk-google-apps on github and it's awesome !
Thanks a lot for this job !

I added it as a library on my google script, but I don't know how to use it in my script.

I just need to use it to send emails with SES API, but I haven't found on Internet how to do that in a google app script.

With the AWS Stack, I'm a newby and I really don't know how to use it from google app script, how to put my credentials, and to call the SES function to send emails.

If you know all this stuff, I would be very grateful if you can send me some examples.

Thank you so much
Thomas

There are some examples provided in the Examples code, e.g.

async function sendEmailTest() {
initConfig(AWS_CONFIG_TEST);
var result = await sendEmail(
'Your Name <you@example.com>', // to
'', // cc
'', // bcc
'Google Apps Script <from@aws-domain.com>', // from
'no-reply@example.com', // reply-to
'Simple email test', // subject
'<html><body><strong>This is an HTML message.</strong> Sent by AWS.</body></html>', // html
);
if (result === false) {
return false;
}
Logger.log(`Sent: ${result.MessageId}`);
return result.MessageId;
}

There are some examples provided in the Examples code, e.g.

async function sendEmailTest() {
initConfig(AWS_CONFIG_TEST);
var result = await sendEmail(
'Your Name <you@example.com>', // to
'', // cc
'', // bcc
'Google Apps Script <from@aws-domain.com>', // from
'no-reply@example.com', // reply-to
'Simple email test', // subject
'<html><body><strong>This is an HTML message.</strong> Sent by AWS.</body></html>', // html
);
if (result === false) {
return false;
}
Logger.log(`Sent: ${result.MessageId}`);
return result.MessageId;
}

Thanks a lot for your quick answer, but I can't see where I put my AWS SES Credentials
Do you have a step by step tutorial ?

I managed to copy all the js file so now I understand where the credentials are, but I have an error saying :
AWS is not defined

in the config.js file

const AWS_CONFIG = {
  accessKey: 'AK0ZXZD0KGNG4KG6REBP', // use your own AWS key
  secretKey: 'EXrPgHC41HEW2YownLUnJLgh6bMsrmW1uva1ic24', // use your own AWS key
  region: 'us-east-1',
};

Please see the README on the homepage. AWS is very complicated, and learning how to use it is out of the scope of this project.