in bigquery-jobs-notifier/run/app.py [0:0]
def notify(message):
if to_emails is None or sendgrid_api_key is None:
app.logger.info("Email notification skipped as TO_EMAILS or SENDGRID_API_KEY is not set")
return
app.logger.info(f"Sending email to {to_emails}")
message = Mail(
from_email='noreply@bigquery-usage-notifier.com',
to_emails=to_emails,
subject='An expensive BigQuery job just completed',
html_content=f'<html><pre>{message}</pre></html>')
try:
app.logger.info(f"Email content {message}")
sg = SendGridAPIClient(sendgrid_api_key)
response = sg.send(message)
app.logger.info(f"Email status code {response.status_code}")
except Exception as e:
print(e)