send_email
Function
Summary:
The send_email
function sends an email with the given subject and body to the given emails. It attaches the given Python cells to the email.
Parameters:
- refs (
list[RefResponse]
): list of Python cells to attach to the email. - emails (
list[str]
): list of emails to send the email to. - subject (
str
): subject of the email. - body (
str
): body of the email.
Response
If the email is sent successfully, the function returns a JSON object with the message "ok". Otherwise, it returns a JSON object which contains error details.
{
"message": "ok"
}
Usage example:
from typing import Dict
import pandas as pd
from morphdb_utils.api import ref, send_email
from morphdb_utils.annotations import api
data = {}
@api
def main(data: Dict[str, pd.DataFrame]):
send_email(
refs=[ref("xxxx")],
emails=["xxxx@email.com"],
subject="Weekly sales meeting report",
body="""Weekly report is attached. Please read them by the meeting."""
)
return {
"message": "ok"
}
This function works particularly well in situations where you want to automate sending emails with reports.