Forum Discussion

anusha_2023's avatar
anusha_2023
Helper IV
4 months ago
Solved

Sending Outlook Email using Data Factory Pipeline

Hi,

 

I have multiple rows for each receiver. I need to send one mail per user only.

 

When I have created Lookup to read Lakehouse table and indide Foreach Outllook component how to send one mail per user by grouping data based on the end user.

 

 

 

  • Hi anusha_2023 ,

    would do it in a simpler way. Here is the order I would follow: (lookup -for each - office 365)

     

    1. Lookup : Add a Lookup pointing to your table with a simple query:

    Select name, email, subject,summary from nameTableLakehouse

    2. ForEach: Connect the Lookup to the ForEach and in the Items field put:

    @activity('NameLookup).output.value

    This tells the ForEach to iterate over all the records returned by the Lookup.

    3. Office 365 - Send an Email: Inside the ForEach add the Send an Email activity:

    • To: @item().Email
    • Subject: @item().subject
    • Body: @item().summary

     

    With this, each iteration of the ForEach sends one email per user with their data. Simple and clean.

     

    If you find this helpful please give it a 👍, and if it answered your question please mark it as a solution . This helps the community and motivates me to keep contributing. Thank you!

6 Replies

  • Hi anusha_2023

     

    Where is the data coming from? 

    Grouping and aggregating this is something that should probably be done at source. You'd also need to define rules to determine which email to send if the same email address has records for different subjects and bodies. 

     

    If you data is in a lakehouse, I'd start with a notebook to clean it, determine one email to send for each user, then write that to a new table. From there you can get at it in your pipeline and there will only be one record per user.  

  • Thanks for your reply. 
    table is cleaned and write to Lakehouse using Notebook.
    Do I need to create a separate table for each user then it would be a big manual task since I have around 50 users at the end. 
    I want to send last three rows in the table format in case of Name "Kesava".

     

    • tayloramy's avatar
      tayloramy
      Super User

      Hi anusha_2023

       

      Don't make a new table for each user, but you should make one new table that contains all the emails you want to send and removes the duplicates. 

       

  • Hi anusha_2023 ,

    would do it in a simpler way. Here is the order I would follow: (lookup -for each - office 365)

     

    1. Lookup : Add a Lookup pointing to your table with a simple query:

    Select name, email, subject,summary from nameTableLakehouse

    2. ForEach: Connect the Lookup to the ForEach and in the Items field put:

    @activity('NameLookup).output.value

    This tells the ForEach to iterate over all the records returned by the Lookup.

    3. Office 365 - Send an Email: Inside the ForEach add the Send an Email activity:

    • To: @item().Email
    • Subject: @item().subject
    • Body: @item().summary

     

    With this, each iteration of the ForEach sends one email per user with their data. Simple and clean.

     

    If you find this helpful please give it a 👍, and if it answered your question please mark it as a solution . This helps the community and motivates me to keep contributing. Thank you!

  • Hi anusha_2023 ,


    Thanks for reaching out to Microsoft Fabric Community.

    Have you had a chance to try the Notebook approach recommended by tayloramy . If yes, did it work for your scenario, or are you still running into any issues?

     

    Please reach out if you need any further assistance.

    Thank you.