Send e-mail in a workflow

Sending an email when a list item was added in some versions of SharePoint required many steps, which you can find detailed below. However, if you are using the most current version of SharePoint, you can add a flow directly from your list. A Microsoft Flow template to send an email when a list item is added includes the basic steps needed to get you started quickly.

Sending email from workflow

Send a basic e-mail message from a workflow

Dynamically select users or groups to receive the message

Include information about the current item

Include a static hyperlink

Include a hyperlink to the current item

Include an image

Identify options that are not supported

Send a basic e-mail message from a workflow

New item triggering workflow to send e-mail message

By using the Send an Email action in the Workflow Designer, you can set up your custom workflow to send e-mail messages to you or to any other specified user or group. The available fields for an e-mail message are To, CC, Subject, and Body. These fields can contain both static text and text that is generated dynamically from workflow lookups.

You can use the Send an Email action to generate many kinds of messages, including notifications when the workflow reaches specified stages or performs specified actions (including the overall starting and stopping of the workflow) and reminders about tasks that are not complete by their due date.

Note: Outgoing e-mail settings must be configured on the server before your workflow can send e-mail messages. If you are unsure about the server's current e-mail settings, check with your server administrator. Find links to more information about outgoing e-mail settings in the See Also section.

In this example, you will set up your workflow to send you an e-mail notification each time that it starts to run on a new item. Use the version of SharePoint Designer that matches your SharePoint Server version. For example, for SharePoint Server 2010 use SharePoint Designer 2010. And, for all version after SharePoint Server 2010, including SharePoint Server 2016 and SharePoint Online, use SharePoint Designer 2013. You can download SharePoint Designer 2013 from the Microsoft Download Center and find more information about it in the See Also section.

Open SharePoint Designer 2013 and connect to a SharePoint site

SharePoint Designer 2013 installs as an Office 2013 application. To open SharePoint Designer 2013 and connect to a SharePoint site follow these steps:

  1. Open SharePoint Designer 2013 by selecting it on the Start menu. Click Start icon, click All Programs, click Microsoft Office 2013, and then click SharePoint Designer 2013.

  2. Click Open Site on the SharePoint Designer 2013 start page.

  3. Enter the SharePoint site that you want to connect to. For example, http://www.contoso.com/sites/a-sharepoint-site.

  4. Click Open to open the site.

  5. Enter your credentials, if prompted. (If security is not integrated with the computer you signed in on then you are prompted to enter your credentials.) Make sure to use credentials that have access to the SharePoint site.

Create a List workflow based on the SharePoint Workflow platform

  1. Click the Workflows node in the Navigation pane.

  2. Click the List Workflow drop-down in the New section of the WORKFLOWS tab.

  3. Select the list that you want to associate with the new workflow.

  4. On the Create List Workflow dialog box, enter a name and description for the workflow and then make sure that the Platform Type is set to SharePoint 2013 Workflow.

Select OK to create the workflow.

Now that the workflow is created, you can add Actions, Conditions, Stages, Steps and Loops to build your workflow. These workflow components are available in the ribbon of SharePoint Designer 2013.

Note: If you do not see SharePoint 2013 Workflow as an available platform type then Workflow Manager is not configured to work with the SharePoint farm. See Configure Workflow Manger to work with the SharePoint Server 2013 Farm.

Find more information about the available list of workflow actions in the See Also Section.

Create the action to send the an email 

  1. Click Actions, and then click Send an Email

  2. In the action, click these users

  3. In the Define E-mail Message dialog box, select users from the existing Users and Groups or enter your own e-mail address in the To box

    Notes: 

    • In order to send an email to an external email address. you must be able to retrieve information from the respective email-server.

    • The To address of a message can either be a specific, static address (for example, NORTHWINDTRADERS\junmin or junmin@northwindtraders.com) or a workflow lookup to variable information. To learn more about using workflow lookups to dynamically address e-mail messages sent from the workflow instead of using static addresses, see the next section Dynamically select users or groups to receive the message.

    • The sender address of the rendered message will always be the e-mail address of the server administrator, unless the server administrator changes the sender address for either the current Web application or all Web applications. To learn more, read Configure Outgoing Email for a specific web app.

  4. In the Subject box, type a subject for the message, or click Display data binding Button image to define a workflow lookup to the text you want here

    Note: You must make some entry in the Subject box in order for the workflow to compile correctly.

  5. In the large box under the Subject box, type or paste the body text of the message

  6. Select OK

  7. Select Action > Go to a stage

  8. Select End of Workflow

  9. Click Publish

More advanced options for modifying the contents of the email are detailed in the following sections.

Top of Page

Dynamically select users or groups to receive the message

If you supply static addresses in the To and Cc fields of your message, then any time that you need to change the recipients, you must open the workflow in the Workflow Designer and make the changes manually. If the addresses will change frequently, it is a better practice to use workflow lookups in the To and Cc fields. Lookups can reference addresses from a field in the current item, from a field in an item in another list or library, or from workflow variables.

Use a custom list to store recipient addresses

If the recipients change periodically, but not often enough that they must be specified on an initiation form each time that the workflow is started, you can create a custom Recipients list that contains one list item for each workflow that references it, and then create columns in which you can store the addresses to which each e-mail message from each workflow is to be sent. When the recipients for any workflow message change, all you have to do is change the addresses in the appropriate field in the Recipients list item for that workflow.

Important: The columns in which you store addresses for workflow e-mail messages can be either Single line of text, Multiple lines of text, or Person or Group type columns. If you use a Person or Group column, only one entry can be made in each field that the workflow will reference for e-mail addresses. When creating the column, be sure to select No under Allow multiple selections. If you want to use this type of column to specify multiple recipients, you can create a SharePoint group that includes the people that you want the workflow to address the e-mail to, and then specify the group in the field. When creating the column, be sure to select People and Groups under Allow selection of. Find a link to more information about creating lists and adding columns in the See Also section.

Note: When creating SharePoint groups, make sure that each group has at least Read permissions for the site, and that in the Group Settings area of the New Group Page, under Who can view the membership of the group, Everyone is selected.

To use a workflow lookup to a custom Recipients list:

  1. In the browser, create a custom list named Recipients with the following three columns:

    • Change the name of the default Title column to Workflow Name. Leave all the other options as it is. Find a link to more information about changing column in a list or library in the See Also section.

    • Add a Person or Group column named To. In this column, allow selection of both People and Groups, but do not allow multiple selections. Leave all the other options as it is. Find a link to more information about creating column in a list or library in the See Also section.

    • Add a Single line of text column named Cc. Leave all the other options as it is.

  2. In the Recipients list, create a new item and then do the following:

    • In the Workflow Name field, type Document Review, which is the name of the example workflow used here.

    • In the To field, click Address Book Button image and then, in the Select People and Groups dialog box, select a single person or group to address messages to.

    • In the Cc field, type the e-mail addresses of the recipients to address copies to, separating multiple addresses with semicolons.

  3. Create a new workflow

  4. Click Actions, and then click Send an Email.

  5. In the Action, click these users.

  6. In the Define E-mail Message dialog box, at the end of the To box, click Address Book Button image .

  7. In the Select Users dialog box, in the Or select from existing Users and Groups list, click Workflow Lookup for a User..., and then click Add.

  8. In the Lookup for Person or Group dialog box, choose the following options:

    • Data Source: Recipients, or the name of your custom list.

    • Field from source: To, or the field that holds the address you want in To line.

    • Return field as: Login Name, This will decide the "To" field format in the email

    • Field: Recipients: Workflow Name

    • Value: Type Document Review, or the name of the current workflow.

      This lookup says, "From the Recipients list, select the value of the To field where the Workflow Name equals Document Review."

      The top half of the dialog box specifies the list and the column; the bottom half of the dialog box specifies the row.

  9. In the Lookup for Person or Group dialog box, click OK.

  10. In the message about ensuring unique lookups, click OK.

  11. Click OK again to close the Select Users dialog box.

  12. In the Define E-mail Message dialog box, at the end of the CC box, click Address Book Button image .

  13. In the Select Users dialog box, in the Or select from existing Users and Groups list, click Workflow Lookup for a User..., and then click Add.

  14. In the Define Workflow Lookup dialog box, choose the following options:

    • Data Source: Recipients, or the name of your custom list.

    • Field from source: Cc, or the field that holds the address you want in Cc line.

    • Return field as:Login Name, This will decide the "To" field format in the email

    • Field: Recipients: Workflow Name

    • Value: Type Document Review, or the name of the current workflow.

      This lookup says, "From the Recipients list, select the value of the Cc field where the Workflow Name equals Document Review."

  15. Click OK, click OK again in the warning message, and then click OK again to close the Select Users dialog box.

Now, when the workflow sends this e-mail message, it sends it to the addresses listed in the To and Cc fields of the Document Review item in the custom Recipients list. To change recipients, simply make the changes you want in the list item.

A single workflow may send multiple e-mail messages, and the messages may not all be sent to the same recipients. To store other addresses for additional messages sent by this workflow, you can add columns to the list to store the other addresses. In this case, you may want to name the columns "First message To," "Second message To," and so on.

Alternatively, you can design the list so that you create one item for each message that the workflow sends, instead of one item for each workflow. In this case, make sure that the name used to identify each message is unique, so that the lookups that retrieve the addresses return the unique value that you want.

Use the workflow initiation form to specify recipients

If you want recipients to be specified each time that a workflow is started manually, you can customize the workflow initiation form to collect the addresses from the person who starts the workflow. The workflow can then either simply use the entered addresses directly, or copy them into fields in the current item — where they will still be available for reference after the workflow has completed its current instance. If the workflow is set up so that it also starts automatically, you can specify default addresses in the initiation form for whenever an automatic start occurs.

Top of Page

Include information about the current item

So far, the body text in the example message is static: Every time the workflow creates an instance of the message, the text will be exactly the same.

It can be useful, however, to include text that changes in relation to the item on which the workflow is currently running. For example, it might be useful to include the title of the document needing review in the body of your message. To include this sort of dynamic information, you use a workflow lookup. Lookups retrieve data from different data sources such as lists, libraries, and workflow data.

To add the title of the document to the message text:

  1. Type or paste the static text within which you want the lookup information to appear.

  2. Position the insertion point where you want the lookup to be located.

    Tip: Once a lookup is inserted, it cannot be dragged to a new location. (It is possible, however, to "relocate" a lookup by dragging other text around it.) Similarly, it is not possible to cut, to copy, or to paste either a lookup or any text that includes a lookup.

  3. Click Add or Change Lookup.

  4. In the Lookupfor String dialog box, select Current Item in the Data Source box and Name in the Field from source box.

  5. Click OK.

  6. The inserted lookup appears in the message body.

  7. Click Publish to publish the workflow.

When the workflow runs and the message is generated, the lookup is replaced by the title of the document.

Inserting Title 5

Including the title of the document is useful, but it might be even more useful to include a hyperlink that would take you directly to the document itself. To do this, you include a lookup in the hyperlink.

Top of Page

Include a static hyperlink

You can include a static hyperlink — one that always links to the same address or location — in the body of your workflow e-mail message by using the Edit Hyperlink button in the upper right corner of the formatting tool panel in Define E-mail Message dialog box.

  1. Type or paste the static text within which you want the link to appear.

  2. Select the text and click Edit Hyperlink .

  3. In the Edit Hyperlink dialogue box , type the address of the web site.

  4. Click OK.

    The inserted hyperlink appears in the message body.

Note: Text-based e-mail programs will not render the hyperlink.

To learn how to use a workflow lookup to create a dynamic hyperlink that points to varying addresses depending on the item on which the workflow is currently running, see the next section, Include a hyperlink to the current item.

Top of Page

Include a hyperlink to the current item

In the previous section, Include a static hyperlink, the address in the example hyperlink includes no variable information: Every time that the workflow sends the e-mail message, the hyperlink points to the same page.

By using a workflow lookup, however, you can create a dynamic link that uses information about the current item to decide which URL to point to.

If the current item is a document in a document library

In the workflow startup notification example, you might want to provide a link to the new document itself:

  1. Type or paste the static text within which you want the link to appear.

  2. Select the text and click Edit Hyperlink.

  3. In the Edit Hyperlink dialogue box, click function (fx).

    Tip: Once a lookup is inserted, it cannot be dragged to a new location. (It is possible, however, to "relocate" a lookup by dragging other text around it.) Similarly, it is not possible to cut, to copy, or to paste either a lookup or any text that includes a lookup.

  4. In the Lookup for String dialog box, select Current Item in the DataSource box.

  5. In the Field from source box, select Encoded Absolute URL, and then click OK.

    Inserting Hyperlink for Current Item 1 Inserting Hyperlink for Current Item 2 Inserting Hyperlink for Current Item 3

When the recipient of the message clicks the link, the document opens for viewing or editing.

If the current item is a list item

When you create a link to a list item — for example, an announcement or a calendar event — you can choose to have the link open either the display form (DispForm.aspx) or the edit form (EditForm.aspx) of the list item.

To create a link that opens the list item:

  1. In the browser, navigate to the list on which you want to create this workflow

  2. Open the list item for any existing document in the library, using View Item if you want your link to open the display form or Edit Item if you want your link to open the edit form

  3. Copy the address in the address bar from the beginning http: or https: through the first equal sign (=)

    Inserting Hyperlink for List Item 1

  4. The ?ID= text is a query string parameter that instructs the page to display the form for whichever item in the current list or library has the list ID that follows the equal sign (=) — which in this example will be the list ID of the current item, as identified by the workflow lookup.

    Note: If the current item is a task that is created by one of the three workflow task actions, and if you want the link to open the custom task form (and not the default display or edit form for the Tasks list), see the later section If the current item is a custom task form. For tasks not created by a workflow task action, and for the display forms of even those tasks created by one of the workflow task actions, the current procedure is all that you need.

  5. In the Define E-mail Message dialog box, type or paste the static text within which you want the link to appear (For example - To view the list item, click here).

  6. Select the text and click Edit Hyperlink

  7. In Edit Hyperlink select String Builder for the address field 

  8. In the String Builder dialogue box, paste the address. 

  9. Position the insertion point directly after the equal sign (=), and then click Add or Change Lookup.

  10. In the Lookup for String dialog box, select Current Item in the Source box and ID in the Fieldfrom source box.

    Inserting Hyperlink for List Item 3

  11. Click OK.

    The final string in String Builder should start with http:// or https:// and end with [%Current Item:ID%] Inserting Hyperlink for List Item 4

    Important: While the current item ID lookup is useful in building links to the current list item, the following lookups can present errors in the rendered path, and are thus not recommended for inclusion in e-mail message links: Path, Server Relative URL, Source URL, and URL path.

  12. Select OK twice

Your links will show in blue text with an underline in the email message.

Inserting Hyperlink for List Item 5

If you plan to use the link more than once, continue to the next section.

Store a list item address as a workflow variable

You can store the URL of the display form or edit form of a list item in a workflow variable, so that you can use it in multiple locations in the same workflow.

  1. In the Workflow Designer window, click Actions, and then click Extract Substring from Index of String

    Variable 1

  2. In the stage, click string and click ellipses button [...]

  3. In the String Builder dialog box, paste the static text portion of the URL (but not the lookup for the current item ID)

    Variable 2

  4. Position the insertion point after the equal sign (=) and then click Add or Change Lookup

  5. In the Lookup for String dialog box, select Current Item in the DataSource box and ID in the Field from source box

    Variable 3

  6. Click OK

    The lookup is added to the text in the dialog box

    Variable 4

  7. Click OK to close the String Builder dialog box

  8. Click 0 in Starting at 0 and replace it with 1

    Note: When Starting at has a value greater than 1, the final string will have characters removed.

  9. Select Variable: substring or Variable: substring1 in Output to Variable: substring

  10. In the list, click Create a new variable and then, in the Edit Variable dialog box, type a name for the new variable

  11. Make sure that Type is set to String, and then click OK Variable 5

  12. Click below the action you just created and Add the Send an email action to the Actions, and then click these users in the action. Variable 6

  13. To use the new variable in the Define E-mail Message dialog box, type or paste the text within which you want link to appear into the message body. Select the text and click Edit Hyperlink from the formatting menu. Click [fx] button or click ellipses button [...] and then click Add or Change Lookup

  14. In the Lookup for String dialog box, in the Data Source box list, select Workflow Variables and Parameters

  15. In the Fieldfrom source list, select Variable: name of variable, and then click OK and OK on the next box

    Variable 7 Define E-mail Message Screen after inserting variable

You can now insert this variable anywhere that you want it in the current workflow.

Top of Page

Include an image

You can include a graphic in your message by creating a variable and using the HTML image tag <img/> to link to an image that is stored as a JPEG (.jpg) file and uploaded to a picture library in your site.

  1. In the Workflow Designer window, click Actions, and then click Set Workflow Variable.

  2. Click workflow variable and select Create a new variable...

  3. In the Edit Variable dialog box, type a name for the new variable and make sure that Type is set to String, and then click OK.

  4. Click value and click ellipses button [...] and in the String Builderwindow, add type or paste the URL for the JPEG image file in HTML tag format - <img src ="URL"/> String Builder for Image

  5. Click OK.

  6. The inserted Action appears like this. Setting Variable for inserting an image

  7. Click below the action you just created and Add the Send an email action to the action and then click These users in the action. Inserting Send an Email Action

  8. In the Define E-mail Message dialogue box, click Add or Change Lookup.

  9. In the Lookup for String dialogue box, in the Data Source list, select Workflow Variables and Parameters.

  10. In the Field from source list, select Variable: Name of Variablee and select OK. Email String in Image Workflow Workflow Email Mesage body with Image

  11. Select OK again to close the Define E-mail Message window and publish the workflow.

 When the message is sent, the image from the JPEG file appears instead of the link tag.

Top of Page

Identify options that are not supported

The following options are not supported by the current version of the Send an Email action:

  • Specifying an address on the From line. (E-mail messages sent by the workflow always show the e-mail address specified by the server administrator on the From line. Only the server administrator can change this, and it can only be changed for all notifications in the current Web application, not per workflow.)

  • Using an embedded cascading style sheet (CSS) to format message content. Text can be formatted by using the style attribute, but the <style> tag and CSS classes are not supported.

  • Using a workflow lookup in either the To or CC box that references a column of the Person or Group type that contains multiple values.

  • Specifying a Bcc recipient for a message

  • Including another file with a message as an attachment.

  • Embedding image or graphic files in a message. Instead, Include an image.

Top of Page

See Also

SharePoint 2013 Step by step: Setup for Outgoing Email Setting

Introducing SharePoint Designer

Configuring Outgoing email for a specific web app

Configure Workflow Manager to work with the SharePoint Server 2013 Farm

Workflow Actions Quick Reference

Create a list in SharePoint

Create a column in a SharePoint list or library

Change a column in a list or library

Create an alert or subscribe to an RSS feed in SharePoint Online, SharePoint 2016, and SharePoint 2013

Create an alert or subscribe to an RSS Feed in SharePoint 2010

Basic Troubleshooting Tips 

The following list of questions may help determine the cause of an issue creating a workflow:

  1. Are you able to create any other type of workflow on the same list? For example, try to create an approval workflow

  2. Are you able to create the same workflow:

    • on a different list on the same site?

    • on a different site under same site collection?

    • on a different site collection under same web application?

    • on a different web application?

    • logged in with a different account?

    • using a different computer?

 Advanced Troubleshooting Tips

If none of the basic troubleshooting tips help determine the cause of a workflow issue, follow the steps below:

  1. Ensure you have required permissions at site and workflow level. Go to Site Settings > Site Permissions > Check Permissions / List Settings > Permissions for this list and verify Check Permissions results match the following:

    1. Minimum permissions to design a workflow (save and publish):

      1. on the SharePoint site: Design

      2. on the SharePoint list: Edit

    2. Minimum permissions to start a workflow:

      1. on the SharePoint site: View Only/Read

      2. on the SharePoint list: Contribute

  2. Ensure outgoing email settings are set to the correct Exchange server.

    1. Open Command Prompt as an administrator

    2. Run nslookup <Exchange server address>. For example: nslookup exch.contoso.com

    3. You should see the resolved IP address of the Exchange server in the output. If not, contact your Exchange administrator and ask for the correct Exchange fully qualified domain name (FDQN).

  3. Send an email to the same person using the SendEmail function of the SPUtility class with SharePoint Management Shell following the steps below.

    1. Open SharePoint Management Shell as an administrator. (Right click SharePoint Management Shell > Run as administrator)

    2. Run the following script. If the script responds with True and the user receives an email from SharePoint, SMTP is configured correctly in SharePoint.

    $Site = "Your Site Name"
    $Email = "User to whom you are sending an email through the workflow"
    $Subject = "Subject Line with the email"
    $Body = "Test Email Body"
    $web = Get-SPWeb $Site
    [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($Web ,0,0,$Email,$Subject,$Body)
    
    # Below is the same script with sample data              
    $Site = "http://sp/"
    $Email = "User1@contoso.com"
    $Subject = "Test Email from SharePoint"
    $Body = "This is a Test Email"
    $web = Get-SPWeb $Site
    [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($Web ,0,0,$Email,$Subject,$Body)
  4. Send an email to the same user from the SharePoint server using SMTP functionality. Follow the steps in Use Telnet to test SMTP communication.

Note: By default, SharePoint does not create log entries for outgoing mails. SharePoint never sends email directly. The email messages are relayed through the SMTP (Exchange) server configured in Central Administration. Follow the steps above for troubleshooting this type of workflow.

Expand your Office skills
Explore training
Get new features first
Join Office Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×