cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dpual1031
Regular Visitor

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 II
Super User II

Hi @dpual1031,

 

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?

View solution in original post

1 REPLY 1
Expiscornovus
Super User II
Super User II

Hi @dpual1031,

 

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?

View solution in original post

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (80,205)