added RRig report sam cli
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"emails": [
|
||||
"nmelone@henry-pump.com"
|
||||
|
||||
],
|
||||
"customers": {
|
||||
"ec691940-52e2-11ec-a919-556e8dbef35c": {
|
||||
|
||||
@@ -146,29 +146,30 @@ def lambda_handler(event, context):
|
||||
|
||||
# Store the generated report in S3.
|
||||
s3.Object(BUCKET_NAME, f'{report_name}-{company_name}-{dt.today().strftime('%Y-%m-%d')}.xlsx').put(Body=open(f"/tmp/{report_name}-{company_name}-{dt.today().strftime('%Y-%m-%d')}.xlsx", 'rb'))
|
||||
# Create an email message
|
||||
msg = MIMEMultipart()
|
||||
msg['Subject'] = report_name
|
||||
msg['From'] = 'alerts@henry-pump.com'
|
||||
msg['To'] = ", ".join(reportToList[report_name])
|
||||
if reportToList[report_name]:
|
||||
# Create an email message
|
||||
msg = MIMEMultipart()
|
||||
msg['Subject'] = report_name
|
||||
msg['From'] = 'alerts@henry-pump.com'
|
||||
msg['To'] = ", ".join(reportToList[report_name])
|
||||
|
||||
# Add a text body to the message (optional)
|
||||
body_text = 'Please find the attached spreadsheets.'
|
||||
msg.attach(MIMEText(body_text, 'plain'))
|
||||
# Add a text body to the message (optional)
|
||||
body_text = 'Please find the attached spreadsheets.'
|
||||
msg.attach(MIMEText(body_text, 'plain'))
|
||||
|
||||
# Attach each workbook in the spreadsheets array
|
||||
for spreadsheet in spreadsheets:
|
||||
# Attach the file to the email message
|
||||
attachment = MIMEBase('application', 'octet-stream')
|
||||
attachment.set_payload(open(spreadsheet.filename, "rb").read())
|
||||
encoders.encode_base64(attachment)
|
||||
attachment.add_header('Content-Disposition', 'attachment', filename=spreadsheet.filename[5:])
|
||||
# Attach each workbook in the spreadsheets array
|
||||
for spreadsheet in spreadsheets:
|
||||
# Attach the file to the email message
|
||||
attachment = MIMEBase('application', 'octet-stream')
|
||||
attachment.set_payload(open(spreadsheet.filename, "rb").read())
|
||||
encoders.encode_base64(attachment)
|
||||
attachment.add_header('Content-Disposition', 'attachment', filename=spreadsheet.filename[5:])
|
||||
|
||||
msg.attach(attachment)
|
||||
# Send the email using AWS SES
|
||||
response = ses_client.send_raw_email(
|
||||
|
||||
RawMessage={'Data': msg.as_string()}
|
||||
)
|
||||
msg.attach(attachment)
|
||||
# Send the email using AWS SES
|
||||
response = ses_client.send_raw_email(
|
||||
|
||||
RawMessage={'Data': msg.as_string()}
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user