How to access an email body when invoking a Lambda Function upon receiving an email through SES?

0

I have a rule to invoke a Lambda Function when SES receives an email. This works fine. I pass Lambda the event as an argument in the handler and assign an email constant a value of "event.Records[0].ses.mail". When console logging this value, I cannot find the content body showing the actual body of the email. Instead, I can only view the subject, recipient, sender, etc. How do I access the body of an email sent to my domain?

This is my current handler:

const handler = async (event) => {
        // Get Email
        const email = event.Records[0].ses.mail // console logs fine, but has no content/email body

       // Get Body
       const body = ?
}

asked 10 months ago923 views
1 Answer
1
Accepted Answer

Instead of triggering on the event of receiving an email in SES, why not trigger when the received email is saved in S3?
Set up an event trigger in the S3 bucket for receiving emails and run Lambda.
When the event is triggered, you can check the body of the email by using Lambda to get_object the object.
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/with-s3-example.html#with-s3-example-create-trigger

profile picture
EXPERT
answered 10 months ago

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