cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Start an email form a SharePoint list item, that is populated with details from the selected item without sending it.

I want to start an email form a SharePoint list item, that is populated with details from the selected item, but the author of the email can complete the email, address the email and then send it when finished. 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @Anonymous,

 

I would say this is possible by using the following approach

- Create a button in a SharePoint list which will trigger the flow

- Create a flow which asks for an e-mail input and use an http with a Graph API create message request (this will create a draft outlook message). This action however does require a App registration in Azure AD and the correct permissions (Mail.ReadWrite):

https://www.lee-ford.co.uk/using-flow-with-graph-api/
https://docs.microsoft.com/en-us/graph/api/user-post-messages?view=graph-rest-1.0

 

Below is an example of such an setup.

 

1. Add a for a selected item trigger action. Add an Email Input

forselecteditem_template.png

2. Add an HTTP action. Use the following URI field value. Notice the x-ms-user-id in the URI. This will make sure that the draft is created in the mailbox of the person who is triggering the flow.

https://graph.microsoft.com/v1.0/users/@{triggerOutputs()['headers']['x-ms-user-id']}/messages

 

3. For the body I am using this example. However, you can add other dynamic values to it if you want. The email of the input is used for the To: field of the draft e-mail.

{
    "subject":"E-mail template flow",
    "importance":"Low",
    "body":{
        "contentType":"HTML",
        "content":"They were <b>awesome</b>!"
    },
    "toRecipients":[
        {
            "emailAddress":{
                "address":"@{triggerBody()['email']}"
            }
        }
    ]
}

 

post_draftmessage.png

 

3. Add the button (formatting) to your SharePoint List. In this example my column is called SendMail. Don't forget to add id of your flow. Below is the json I used in my example.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\":\"yourflowid\", \"headerText\":\"Example E-mail Template\",\"runFlowButtonText\":\"Send E-mail\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover",
    "title": "Launch Flow"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "Mail"
      }
    }
  ]
}

 

sendmail_formatting.png

 

The end result should look something like this

 

1. Trigger flow from the SendMail button

example_emaildraft.png

 

2. Draft e-mail in the Drafts folder of the user who triggered the flow.

draftemailexample.png

 

Hope this helps to get you started?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

1 REPLY 1
Expiscornovus
Super User
Super User

Hi @Anonymous,

 

I would say this is possible by using the following approach

- Create a button in a SharePoint list which will trigger the flow

- Create a flow which asks for an e-mail input and use an http with a Graph API create message request (this will create a draft outlook message). This action however does require a App registration in Azure AD and the correct permissions (Mail.ReadWrite):

https://www.lee-ford.co.uk/using-flow-with-graph-api/
https://docs.microsoft.com/en-us/graph/api/user-post-messages?view=graph-rest-1.0

 

Below is an example of such an setup.

 

1. Add a for a selected item trigger action. Add an Email Input

forselecteditem_template.png

2. Add an HTTP action. Use the following URI field value. Notice the x-ms-user-id in the URI. This will make sure that the draft is created in the mailbox of the person who is triggering the flow.

https://graph.microsoft.com/v1.0/users/@{triggerOutputs()['headers']['x-ms-user-id']}/messages

 

3. For the body I am using this example. However, you can add other dynamic values to it if you want. The email of the input is used for the To: field of the draft e-mail.

{
    "subject":"E-mail template flow",
    "importance":"Low",
    "body":{
        "contentType":"HTML",
        "content":"They were <b>awesome</b>!"
    },
    "toRecipients":[
        {
            "emailAddress":{
                "address":"@{triggerBody()['email']}"
            }
        }
    ]
}

 

post_draftmessage.png

 

3. Add the button (formatting) to your SharePoint List. In this example my column is called SendMail. Don't forget to add id of your flow. Below is the json I used in my example.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\":\"yourflowid\", \"headerText\":\"Example E-mail Template\",\"runFlowButtonText\":\"Send E-mail\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover",
    "title": "Launch Flow"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "Mail"
      }
    }
  ]
}

 

sendmail_formatting.png

 

The end result should look something like this

 

1. Trigger flow from the SendMail button

example_emaildraft.png

 

2. Draft e-mail in the Drafts folder of the user who triggered the flow.

draftemailexample.png

 

Hope this helps to get you started?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (4,354)