Forum Discussion
Setting up a draft email dynamically on each user's clicking on a Power Automate Button
- 1 year ago
Hi ATB1999 , Thank you for reaching out to the Microsoft Community Forum.
This isn’t possible using Power BI and Power Automate alone, because flows run under the creator’s account, so actions like drafting an email will always affect your mailbox, not the user's.
The only way to draft the email in the clicking user’s inbox is by using the Microsoft Graph API with delegated permissions, which allows actions to run as the signed-in user. You can capture the user’s email in Power BI using USERPRINCIPALNAME(), then pass it to a flow via a button parameter. Inside the flow, format your table as HTML and use an HTTP action to call: POST https://graph.microsoft.com/v1.0/me/messages with a request body that sets isDraft: true. This creates the draft in the signed-in user’s mailbox.
To make this work, you'll need to register an Azure AD app with Mail.ReadWrite (delegated) permission and either use a custom connector or trigger the flow from Power Apps, which runs in the user’s context.
If this helped solve the issue, please consider marking it “Accept as Solution” and giving a ‘Kudos’ so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
Hi. This is interesting. I'm really not sure if this will work but I was thinking about getting data from the dataset directly after the button. Once the button was clicked, call for executing a query to the semantic model. The DAX query executed could be just
EVALUATE {[MeasureWithUserName]}
That might bring the email back.
The measure it's just MeasureName = USERNAME() or try MeasureName = USERPRINCIPALNAME()
As guide to get started you can check this article (translate it to english) for understanding how query datasets from Power Automate to Power Bi works.
https://blog.ladataweb.com.ar/post/746743853368918016/powerbipowerautomate-enviar-notificación-de
I hope that helps,