Need to send email with Attachment from Matillion Tool

867 Views Asked by At

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

There are 2 best solutions below

2
On

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)
0
On

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..