Automate Email Sending with SharePoint Rest API via Power
Image Source: Shutterstock.com
Power Automate
Feb 16, 2024 11:38 AM

Automate Email Sending with SharePoint Rest API via Power

by HubSite 365 about Angelo Gulisano [MVP]

Productivity Solutions Manager presso Npo Sistemi | Microsoft Certified Trainer

Citizen DeveloperPower AutomateLearning Selection

Boost SharePoint Productivity: Send Emails via REST API with Power Automate!

Key insights

5 Key Insights from the Power Automate and SharePoint Integration

  • Send emails through SharePoint: Use the "sendMail" method in SP.Utilities.Utility to send emails directly from SharePoint by leveraging Power Automate.

  • Restrictions to note: Emails can only be sent to authenticated SharePoint users, cannot include attachments (except inline ones in the same domain), and won't work for distribution groups or lists.

  • How to build a flow: Create a manual cloud flow or incorporate a SharePoint HTTP request to send an email where needed, using specific parameters and headers.

  • Email body and recipients: Within the email's body, HTML content is supported, and recipients (“To” field) must be structured as an array in the JSON payload.

  • Practical use case: This method suits scenarios where sending emails through a service account or personal address is not viable or preferred, increasing flexibility in communication strategies.

Understanding SharePoint and Power Automate for Email Automation

Integrating SharePoint with Power Automate to automate email sending tasks is a powerful method that enhances communication and efficiency within organizations. The technique involves utilizing the "sendMail" function within SharePoint's SP.Utilities.Utility for direct email dispatch to SharePoint users. Although this process is subject to certain limitations — such as attachment restrictions and the inability to reach distribution groups — it offers a specialized solution in instances where conventional email sending methods through Outlook 365 are impractical or undesired. By structuring a manual cloud flow or integrating a SharePoint HTTP request, users can tailor email content, manage recipient details dynamically, and execute communications seamlessly. This approach is particularly beneficial for advanced Power Automate users looking to streamline notifications, alerts, and messages within their SharePoint environments, thereby enhancing their workflow automation capabilities and organizational communication strategies.

Power Automate – Send email from SharePoint Rest Api

Today, I'm excited to discuss a technique for sending emails using a REST API in SharePoint, utilizing the "sendMail" method from SP.Utilities.Utility. This method allows messages to be sent directly to SharePoint users.

However, there are important considerations to keep in mind. Recipients need to be authenticated SharePoint users, attachments other than inline ones hosted on the same domain cannot be included, and emails cannot be sent to distribution groups or lists. Moreover, the "To" field is expected to be an array format.

Building the Flow

In this guide, Angelo Gulisano [MVP] outlines the steps for creating a manually triggered cloud flow, which can alternatively be triggered by any necessary event or incorporated with a SharePoint HTTP request for email dispatch. The process involves utilizing the "Send an HTTP request to SharePoint" connector.

When configuring this connector, several parameters need to be set: the SharePoint site address for the call, the method as POST, and the specific URI for sending emails. Additionally, both "accept" and "content-type" headers must be set to "application/json;odata=verbose".

The body of the request should include the recipient's email address, any desired message in HTML format within the "Body" field, and a subject line. This setup allows for the addition of CC or BCC recipients as well.

Why This Method?

The article addresses why this approach might be preferable. Angelo was inspired to write this after conducting a Power Automate training session for a client who needed an alternative method for sending emails without using a service account or his own email address with the standard Outlook 365 connector.

This method provides a flexible and practical solution for sending emails from SharePoint without the limitations or requirements of traditional email services.

Understanding Power Automate in SharePoint

Power Automate plays a crucial role in automating business processes and workflows within SharePoint, allowing users to create automated actions based on specific triggers. This tool is particularly useful for SharePoint users looking to streamline their tasks without the need for complex coding. Whether it's sending email notifications, organizing documents, or automating data collection, Power Automate offers a robust solution for enhancing efficiency and productivity in SharePoint environments. By leveraging Power Automate, businesses can ensure their SharePoint sites not only serve as static repositories of information but also as dynamic platforms that facilitate seamless operations and communication. This system, with its ability to integrate closely with SharePoint, exemplifies the potential for automation to transform how organizations manage and execute their workflows, making it easier than ever to maintain an organized, efficient digital workspace.

Power Automate

Power Automate – Send email from SharePoint Rest Api Hello, today I want to share with you a method to send emails with Power Automate by using a REST API available in SharePoint. There is a method called “sendMail” in SP.Utilities.Utility that can be used to send emails to users. Some attention points:

  • Recipients must be authenticated SharePoint users.
  • Attachments cannot be included through this API method (You can include inline attachments likes images uploaded in the same SharePoint domain).
  • It doesn’t send emails to distribution groups or lists.
  • “To” field must be an array.

In this article, I’m going to create a cloud flow that can be run manually. Of course, you can use any trigger that you need, or you can incorporate a SharePoint HTTP request to send an email wherever necessary. To send mail you should simply add “Send an HTTP request to SharePoint” connector:

  • Site address: SharePoint to use to make call
  • Method: POST
  • URI: /_api/SP.Utilities.Utility.SendEmail

In the body section, you should add “TO” as an object with a result property that accepts an array of email addresses. Similarly, if you want to add “CC” or “BCC“, you can also include “Body“, which can contain HTML, and “Subject” as a string. This is result:

Some people ask me, “Why should I use this option?” I wrote this article inspired by a recent training course on Power Automate that I delivered for a customer. In this instance, my client needed to send emails, but didn’t have the option to use a service account to send emails with the standard Outlook 365 connector, and he didn’t want to send them from his email address. I hope these information can help you.

More on Power Automate and SharePoint Integration

Integrating SharePoint with modern automation services like Power Automate provides a powerful combination for businesses seeking to enhance their productivity and streamline their operations. This approach allows for the creation of automated workflows that can perform a multitude of tasks, from simple notifications to complex data processing. Utilizing SharePoint's REST API in conjunction with Power Automate enables users to tailor these workflows to their specific needs, such as sending customized emails or managing data across platforms. The ability to harness these tools effectively opens up new avenues for improving efficiency, collaboration, and overall digital strategy within an organization. As technology continues to evolve, leveraging these integrations will become increasingly crucial for staying competitive in the digital landscape.

Power Automate - Automate Email Sending with SharePoint Rest API via Power

Read the full article Power Automate – Send email from SharePoint Rest Api

People also ask

How do I use SharePoint REST API in Power Automate?

Utilizing Power Automate to create a new item within a SharePoint list through the REST API is an effective method.

How do I send an email using REST API?

To send an email via REST API, a request can be made to SMTPeter, including details such as the sender, recipient, subject, and body of the email. This example showcases a basic implementation, but more complex emails with HTML content or attachments can also be dispatched.

Can SharePoint automate emails?

Yes, by leveraging Microsoft Power Automate, it's possible to set up automated emails that are dispatched in response to the addition or modification of data. Additionally, email metadata can be systematically captured within SharePoint.

Can Power Automate send emails from anyone?

Power Automate offers a 'send as' feature, allowing emails to be sent either as or on behalf of another individual, assuming you have the required permissions in Outlook for such actions. Emails sent in this manner will appear within the 'Sent Items' folder in Outlook.

Keywords

Power Automate, Send Email, SharePoint, REST API, Flow Automation, SharePoint Integration, Automated Email, SharePoint Workflow, Microsoft Flow, Email Notification