Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Email with attachment

Hi all,

Can you provide help.

Do you maybe have python script or any other script, that I can use to get file from location on S3 bucket and sent it as attachment via email to specific email address?


2 Community Answers

Matillion Agent  

Paul Johnson —

Hi Andrea,

Are you wanting to send the link to a file in s3 or actually add the file as an attachment?

To get you started started here is some code you can paste into a python component to send a basic email with no attachments.

If you want to extend this to add an attachment you will need to build a multi-part MIME message. There is a useful guide that may help with that.

import boto3
from botocore.exceptions import ClientError

# Create a new SES resource and specify a region.
client = boto3.client('ses',region_name=AWS_Region)

# Try to send the email.
    #Provide the contents of the email.
    response = client.send_email(
            'ToAddresses': [
            'Body': {
                'Html': {
                    'Charset': Charset,
                    'Data': Body_HTML,
                'Text': {
                    'Charset': Charset,
                    'Data': Body_Text,
            'Subject': {
                'Charset': Charset,
                'Data': Subject,

# Display an error if something goes wrong.	
except ClientError as e:
    print("Email sent! Message ID:"),
    print("Message: "),
    print Body_Text 

Hope this helps,

Andrea Miljus —

Hi Paul,

Sorry for late answer but I did't get your answer on mail.

We also managed to send mail without attachment.
I will check the link that you sent and I will get back to you with update.


Post Your Community Answer

To add an answer please login