4 weeks ago
4 weeks ago
Hi @SantiNath_Dey,
There isnโt a native feature to embed a Delta table directly into an email body.
You can build custom code to read the Delta table, format part of it as HTML, and send it through your companyโs email service if one is available. In practice, Iโd recommend showing only a small preview in the email rather than trying to inline the full table, and then attaching a file only if that is truly required.
That said, this approach can get complicated fairly quickly. It adds custom logic, ongoing maintenance overhead, and potentially compliance concerns if the table contains PII or other sensitive data.
If there is a hard requirement to send a file, then yes, generating an attachment is possible. But as a best practice, I would usually recommend...
The main downside with attachments is that they go stale immediately, and large files can also hit email size limits or get blocked by mail systems. A live dashboard or shared table is usually a cleaner and more maintainable approach over time.
If this answer resolves your question, could you mark it as โAccept as Solutionโ? That helps other users quickly find the correct fix.
4 weeks ago
Hi @SantiNath_Dey Databricks jobs/workflows handle orchestration be only for status alerts(Success, Failure, Completion), Delta table data can't be send as content of the email, To send delta table as an email you will need a workflow task that reads the table and build an email, saves the same data as a CSV/Excel file (for the attachment), and send it through external email service like SMTP, Microsoft graph etc.
4 weeks ago
Hi @SantiNath_Dey,
There isnโt a native feature to embed a Delta table directly into an email body.
You can build custom code to read the Delta table, format part of it as HTML, and send it through your companyโs email service if one is available. In practice, Iโd recommend showing only a small preview in the email rather than trying to inline the full table, and then attaching a file only if that is truly required.
That said, this approach can get complicated fairly quickly. It adds custom logic, ongoing maintenance overhead, and potentially compliance concerns if the table contains PII or other sensitive data.
If there is a hard requirement to send a file, then yes, generating an attachment is possible. But as a best practice, I would usually recommend...
The main downside with attachments is that they go stale immediately, and large files can also hit email size limits or get blocked by mail systems. A live dashboard or shared table is usually a cleaner and more maintainable approach over time.
If this answer resolves your question, could you mark it as โAccept as Solutionโ? That helps other users quickly find the correct fix.
4 weeks ago
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
fromaddr = "EMAIL address of the sender"
toaddr = "EMAIL address of the receiver"
# instance of MIMEMultipart
msg = MIMEMultipart()
# storing the senders email address
msg['From'] = fromaddr
# storing the receivers email address
msg['To'] = toaddr
# storing the subject
msg['Subject'] = "Subject of the Mail"
# string to store the body of the mail
body = "Body_of_the_mail"
# attach the body with the msg instance
msg.attach(MIMEText(body, 'plain'))
# open the file to be sent
filename = "File_name_with_extension"
attachment = open("Path of the file", "rb")
# instance of MIMEBase and named as p
p = MIMEBase('application', 'octet-stream')
# To change the payload into encoded form
p.set_payload((attachment).read())
# encode into base64
encoders.encode_base64(p)
p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
# attach the instance 'p' to instance 'msg'
msg.attach(p)
# creates SMTP session
s = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
s.starttls()
# Authentication
s.login(fromaddr, "Password_of_the_sender")
# Converts the Multipart msg into a string
text = msg.as_string()
# sending the mail
s.sendmail(fromaddr, toaddr, text)
# terminating the session
s.quit()4 weeks ago
thank you for quick response