0

Need to send email with Attachment from Matillion Tool

I have checked SNS Message,Send Email component from Matillion but it does not have attachment option.

I have Error log table into Amazon Redshift and I want to retrieve those records and load into one file on daily basis( can be put on S3/SFTP ) this file I want to add as attachment to email and send it to vendor for further analysis.

Found this : https://metlcommunity.matillion.com/s/question/0D54G00007lwu2DSAQ/send-email-with-attachment-of-errors but couldn't help.

https://metlcommunity.matillion.com/s/question/0D54G00007lwu2DSAQ/send-email-with-attachment-of-errors

2 Answers 2

0

Based on this message on the Matillion site, it looks like currently there is no built-in component for sending an email with an attachment, but it is on the product roadmap to add one.

There are some hosted downloadable jobs that can send emails - e.g. this and this. It is not clear if they can handle attachments, but at least the Python code inside them might be helpful..

Sign up to request clarification or add additional context in comments.

Comments

0

You can do this with the python component in Matillion.

If the target file is on S3, you can use the python boto3 package to download the file to the matillion server.

Then you can use the smtp package in python to create the email and attach the file.

this is example code to attach a file where the filename is in the variable filename_out

filename_out = "/tmp/" + "myfile.logs"  
part = MIMEBase('application', "octet-stream")
part.set_payload(open(filename_out, "rb").read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename=' + filename_out)
message.attach(part)

2 Comments

:S3.Bucket(Bucket).download_file(Key, 'ErrorFile.csv') I have added this code so is this by default going to download file to /tmp/ location ?
#S3.Bucket(Bucket).download_file(Key, 'ErrorFile.csv') I have added this script for downloading file onto matillion server , so is it going to download the s3 file into /tmp/ location or do we need to specify any location ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.