0

Basically I have a databricks notebook which has an if condition, where if the condition is True, I wish to send an email to users.

For example:

if ( (df.query('documenttype_id == 20').shape[0] > 0)==True ): True

If the code above evaluates to True, I wish to send out an email detailing why it is True etc. Is it possible to do this? I already know how to create Job emails for Successes and Failures, but I'm not sure how to create a Job which will send out an email based on if a value is True or False etc. (Databricks Alerts can't be used by me unfortunately).

EDIT: Sorry I should have been a little clearer, this question is about email creation - how do I send an email using Databricks if the check condition above is True?

  • Just to be clear, do you have a notebook that can send email ? if so you could maybe trigger the notebook after the check ? not really clear if the question is about help for email creation or the check logic - which you already have provided... – rainingdistros Jan 27 '23 at 09:42
  • Actually that's basically my question - how do I set up my notebook so that it will send an email if the check is `True`, so this question is about email creation :) – ImNotSureAboutStats Jan 29 '23 at 23:52
  • For sending email you can find several questions - An [example](https://stackoverflow.com/questions/67088891/send-email-from-databricks-notebook-with-attachment) Reg. trigger - again multiple ways - you could wrap the email as a function and then trigger it based on condition - you could have separate functions for success and failure or you could modify the msg to same function. Or you could have it as a separate task that accepts a task variable and then trigger action based on it - [TaskVariable](https://docs.databricks.com/dev-tools/databricks-utils.html#jobs-utility-dbutilsjobs) – rainingdistros Jan 30 '23 at 06:58

0 Answers0