Jonathon Silva walks through how to use Power Automate to send an email and a Teams message when a user selects an item in a SharePoint list. This process enables streamlined communication with one or multiple recipients directly from SharePoint.
Setting Up the Flow
- The flow is triggered manually using the “For a selected item” trigger in SharePoint.
- It must be created in the company’s default environment to function correctly.
- Inputs are added to the trigger to collect:
- Email address(es) to send to
- Yes/No options for sending via Teams and/or Email
- Optional comments
Retrieving SharePoint Item Data
- Since the trigger doesn’t provide full dynamic content, a “Get item” action is used to retrieve the selected item’s details.
- This ensures access to all necessary fields like title, due date, and technology used.
Conditional Logic for Messaging
- Email Condition:
- If the user selects to send an email, the flow uses the “Send an email (V2)” action.
- Dynamic content is used to personalize the message with:
- Sender’s username
- Project title
- Formatted due date
- Technology used
- Additional comments
- Teams Condition:
- If the user selects to send a Teams message, the flow uses “Post message in a chat or channel.”
- Since Teams only supports one recipient per message, the flow uses an “Apply to each” loop.
- The email string is split using the
split()
expression and a semicolon delimiter.
- Each recipient receives an individual Teams message with the same content as the email.
Testing the Flow
- The flow is tested by selecting a SharePoint item and entering the required inputs.
- Messages are successfully sent to multiple recipients via both email and Teams.
- Email supports multiple recipients in one message, while Teams requires individual messages.
Key Takeaways
- Use the default environment for SharePoint-triggered flows.
- Always retrieve the full item data using “Get item.”
- Use conditional logic to handle different messaging channels.
- Loop through recipients when sending Teams messages to multiple users.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Automate and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.