Automate sending emails with attachments when file in S3 is updated?

0

I have a file in my S3 bucket that is updated daily and I want to automate sending that file as an email attachment whenever it gets updated, using SES. There are some guides that explain this but I have not been able to get any of them to work and I do not know how to code. I have followed the guides in the two links below and am able to automate sending an email when the S3 file is updated but cannot figure out how to include an attachment. Hoping someone can advise what JSON code I can use to make this work. If there are multiple steps involved I will need it in layman's terms because again, I do not know how to code.

https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html https://repost.aws/knowledge-center/lambda-send-email-ses

2 Answers
1

You can't do this without some coding. You'd need to use the raw email API instead, see https://docs.aws.amazon.com/ses/latest/dg/send-email-raw.html. This will require you to write some code to read the file from S3, and create the message.

If you are OK with sending a link to the file instead of attaching it, it might be easier to generate a presigned URL (https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html) and putting that in the message text.

profile picture
answered a year ago
  • Thanks for your reply. In my particular use case it has to be an attachment, so the second link won't work for me. The first link gives really vague guidance on how to include attachments, perhaps it would make sense to a software developer but I wouldn't know how to build this code myself. Ultimately I'm looking for a guide more like what the second person responded with but I tried that yesterday and didn't work.

0

Here is a good example on how to use Lambda Functions to send attachments in email using SES: https://mrrishisingh.medium.com/email-s3-objects-as-attachment-7a534e78601c

Although I agree with the previous answer that it is easier and more elegant to just send the pre-signed URL in the email body because the recipient(s) will not have to use the extra bandwidth to download the file that comes with the attachment in the email.

This will also have impacts on the costs since sending attachments will incur $0.12 for each GB of attachments you send vs $0.0004 per 1,000 GET Requests directly from S3 plus the data Transfer Out at $0.09 per GB

AWS
Nuno_Q
answered a year ago
  • Thanks for your reply. I did try this link yesterday and definitely feel like I followed all the steps as outlined but it didn't work. Perhaps I didn't update the code correctly but I figure I just need to update at the top where it says "sender = abc@abc.com" to the correct email as well as update the two rows below that: recipient and region.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions