Forum Discussion

AJAJ's avatar
AJAJ
Icon for Helper IV rankHelper IV
8 months ago
Solved

ETL Email Summary Notifications

Hi,

 

I'm looking for an email to be triggered with the below details from a fabric table (all the below details are already in a table). Just need to be email presentably. Might have 50 entries. 

 

Appreciate suggestion how do i go about it? Copy activity? or something else?

 

 

  • You can do everything inside Fabric using a Notebook.

     

    1. Notebook reads the Fabric table

      • From a Warehouse → SQL query

      • From a Lakehouse → Spark DataFrame

    2. Convert the result (up to 50 rows is perfect) into HTML

    3. Send the email using SMTP (company mail server or Microsoft SMTP)

    import pandas as pd
    import smtplib
    from email.mime.text import MIMEText
    
    # 1. Query data (example with pandas df already loaded)
    html_table = df.to_html(index=False, border=1)
    
    # 2. Build email
    msg = MIMEText(html_table, "html")
    msg["Subject"] = "Fabric ETL Summary"
    msg["From"] = "[email protected]"
    msg["To"] = "[email protected]"
    
    # 3. Send
    with smtplib.SMTP("smtp.company.com", 587) as server:
        server.starttls()
        server.login("[email protected]", "password")
        server.send_message(msg)

     

3 Replies

  • You can do everything inside Fabric using a Notebook.

     

    1. Notebook reads the Fabric table

      • From a Warehouse → SQL query

      • From a Lakehouse → Spark DataFrame

    2. Convert the result (up to 50 rows is perfect) into HTML

    3. Send the email using SMTP (company mail server or Microsoft SMTP)

    import pandas as pd
    import smtplib
    from email.mime.text import MIMEText
    
    # 1. Query data (example with pandas df already loaded)
    html_table = df.to_html(index=False, border=1)
    
    # 2. Build email
    msg = MIMEText(html_table, "html")
    msg["Subject"] = "Fabric ETL Summary"
    msg["From"] = "[email protected]"
    msg["To"] = "[email protected]"
    
    # 3. Send
    with smtplib.SMTP("smtp.company.com", 587) as server:
        server.starttls()
        server.login("[email protected]", "password")
        server.send_message(msg)

     

  • Hi there,

     

    I'm looking for an email to be triggered with the below details from a fabric table (all the below details are already in a table). Just need to be email presentably. Might have 50 entries. 

     

    Appreciate suggestion how do i go about it? Copy activity? or something else?

     

     

  • Hi AJAJ , perhaps a relevant question to suggest an approach would be, if you want one email with all 50 entries in a table, or 50 separate emails (one per row)?

     

    #1. if 50 separate emails (one per row), I think the most straight forward will be using Data pipelines using a combination of a lookup + foreach + Office 365 email activities.  

     

     

    #2. if you want one email with all 50 entries in a table perhaps a better option is to use Notebook using Python + MSAL + Microsoft Graph. 

    1. Reads your Fabric table into a Pandas DataFrame.
    2. Converts the DataFrame to a clean HTML table (striped rows, responsive width).
    3. Sends one email (to one or many recipients) using the Microsoft Graph sendMail API with app-only (client credentials).  

     

    Of course both #1 & #2 can be achieve with both Data pipelines and Notebook, I'm picking just the most strightforward per use case 😉 ... if you are not familiar with Python, just ask ChatGPT and it will generate the notebook for you. 

     

    Hope my suggestions are useful, if so, I would appreciate a thumbs-up, mark this as solution if appropiate... best of lucks mate!