im trying to use Lambda to create a function that will allow me to send an automated email that says good morning everyday at a specific time. this is for a class project.
the code i currently have for the function is:
obviously where i wrote email i will be inputing the corresponding email
// index.mjs
import AWS from 'aws-sdk';
const ses = new AWS.SES({ region: 'us-east-1' });
export async function handler(event, context) {
const params = {
Destination: {
ToAddresses: ['[email protected]'],
},
Message: {
Body: {
Text: { Data: 'Good morning!' },
},
Subject: { Data: 'Good Morning Greeting' },
},
Source: '[email protected]',
};
try {
await ses.sendEmail(params).promise();
console.log('Email sent successfully');
return { statusCode: 200, body: 'Email sent successfully' };
} catch (err) {
console.error('Error sending email:', err);
return { statusCode: 500, body: 'Error sending email' };
}
}
New contributor
Daniel Cohen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.