Send e-mail in a workflow

Applies to: SharePoint Server 2013 Enterprise, SharePoint Server 2013, SharePoint Server 2010, SharePoint Designer 2007.

Sending an e-mail once a list item was inserted in some versions of SharePoint needed several 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 e-mail when a list item is added contains the first steps required to get you started quickly.

Sending e-mail 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 employing the Send an E-mail 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 include both static text and text that is formed dynamically from workflow lookups.

You can use the Send an E-mail action to formulate multiple types 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 Centre 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. Launch SharePoint Designer 2013 by clicking it on the Start menu. Press Start icon, select All Programs, click Microsoft Office 2013, and then press SharePoint Designer 2013.
  1. Pick Open Site on the SharePoint Designer 2013 start page.
  1. Type your desired SharePoint site to connect to. For example, http://www.contoso.com/sites/a-sharepoint-site.
  1. Press Open to open the site.
  1. Input your credentials, if asked. (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. Select the Workflows node in the Navigation pane.
  1. Click the List Workflow drop-down in the New section of the WORKFLOWS tab.
  1. Choose your preferred list to link with the new workflow.
  1. On the Create List Workflow dialogue box, state a name and description for the workflow and then ensure that the Platform Type is set to SharePoint 2013 Workflow.
  1. Select OK to create the workflow.

Now that the workflow is designed, you can insert Actions, Conditions, Stages, Steps and Loops to develop your workflow. These workflow elements 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 e-mail

  1. Click Actions, and then click Send an E-mail.
  1. In the action, click these users.
  1. In the Define E-mail Message dialogue box, choose users from the existing Users and Groups or type your own e-mail address in the To box.

Notes: 

  • In order to send an e-mail to an external e-mail address, you have to be able to retrieve information from the respective e-mail-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 constantly 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.
  1. In the Subject field, type a subject for the e-mail, click Display data binding Button image to define a workflow lookup for your desired text here.

Note: For the workflow to compile correctly, you must make some entry in the Subject field.

  1. In the large box below the Subject box, enter or paste the body text of the message.
  1. Press OK.
  1. Click Action > Go to a stage.
  1. Choose End of Workflow.
  1. Click Publish.

More advanced options for modifying the contents of the e-mail are detailed in the following sections.

Dynamically select users or groups to receive the message

If you deploy static addresses in the To and Cc fields of your message, then any time that you need to edit the recipients, you must launch the workflow in the Workflow Designer and manually update the changes. If the addresses will revise regularly, it is a more valuable practice to use workflow lookups in the To and Cc fields. Lookups can reference addresses from a field in the existing 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 every specific date, but not frequently enough that they must be specified on an initiation form each time that the workflow is started, you can design a custom Recipients list that includes one list item for each workflow that references it, and then form columns in which you can store the addresses to which each e-mail message from each workflow is to be sent. Once the recipients for any workflow message change, you simply must alter 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, manufacture a custom list called Recipients with the following three columns:
  • Update the name of the default Title column to Workflow Name. Avoid altering the current settings of other options. Find a link to more information about changing column in a list or library in the See Also section.
  • Insert a Person or Group column named To. In this column, enable selection of both People and Groups, but avoid permitting several 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.
  • Insert a Single line of text column named Cc. Leave all the other options as it is.
  1. In the Recipients list, create a new item, and then do the following:
  • In the Workflow Name field, state 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 dialogue, pick a single person or group to address e-mails to.
  • In the Cc field, type the e-mail addresses of the recipients to address copies to, separating several addresses with semicolons.
  1. Create a new workflow
  1. Press Actions, and then select Send an E-mail.
  1. In the Action, click these users.
  1. In the Define E-mail Message dialogue box, at the end of the To box, click Address Book  Button image
  1. In the Select Users dialogue box, in the Or select from existing Users and Groups list, click Workflow Lookup for a User…, and then click Add.
  1. In the Lookup for Person or Group dialogue 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 e-mail.
  • 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 dialogue box elaborates the list and the column; the bottom half of the dialogue box clarifies the row.

  1. In the Lookup for Person or Group dialogue box, click OK.
  1. In the message about ensuring unique lookups, click OK.
  1. Click OK again to close the Select Users dialogue box.

  1. In the Define E-mail Message dialogue box, at the end of the CC box, click Address Book Button image .
  1. In the Select Users dialogue, in the Or select from existing Users and Groups list, press Workflow Lookup for a User, and then pick Add.
  1. In the Define Workflow Lookup dialogue 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 e-mail.
  • 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.”

The top half of the dialogue box elaborates the list and the column; the bottom half of the dialogue box clarifies the row.

  1. Click OK, click OK again in the warning message.
  1. Click OK to close the Select Users dialogue 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 edit recipients, just apply your preferred changes in the list item. A single workflow may send several e-mail messages, and the messages may not presumably be sent to the same recipients. To store other addresses for additional messages sent by this workflow, you can insert 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 create the list so that you create one item for each message that the workflow sends, rather than one item for each workflow. In this case, check 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 customise the workflow initiation form to capture the addresses from the workflow starter. The workflow can then either only use the entered addresses directly, or transfer 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 begins instinctively, you can define standard addresses in the initiation form for whenever an automatic start occurs.

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 remain consistent.

It can be helpful, however, to add dynamic text 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 contain this type of dynamic information, you use a workflow lookup. Lookups retrieve data from different data sources like lists, libraries, and workflow data.

To insert 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.
  1. 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.

  1. Click Add or Change Lookup.
  1. In the Lookupfor String dialogue box, pick Current Item in the Data Source box and Name in the Field from source box.
  1. Click OK.
  1. The inserted lookup appears in the message body.
  1. 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.
  1. Select the text and click Edit Hyperlink.
  1. In the Edit Hyperlink dialogue box, type the address of the website.
  1. Click OK. The inserted hyperlink appears in the message body.

Note: Text-based e-mail programmes 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.

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.
  1. Select the text and click Edit Hyperlink.
  1. 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.

  1. In the Lookup for String dialogue box, click Current Item in the DataSource box.
  1. In the Field from source box, pick 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.
  1. 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.
  1. Copy the address in the address bar from the beginning http: or https: through the first equal sign (=).
Inserting Hyperlink for List Item 1
  1. 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.

  1. In the Define E-mail Message dialogue box, type or paste the static text within which you want the link to appear (For example – To view the list item, click here).
  1. Select the text and click Edit Hyperlink.
  1. In Edit Hyperlink select String Builder for the address field.
  1. In the String Builder dialogue box, paste the address.
  1. Position the insertion point directly after the equal sign (=), and then click Add or Change Lookup.
  1. In the Lookup for String dialogue box, select Current Item in the Source box and ID in the Fieldfrom source box.
Inserting Hyperlink for List Item 3
  1. 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.

  1. 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
  1. In the stage, click string and click ellipses button […]

  1. In the String Builder dialogue box, paste the static text portion of the URL (but not the lookup for the current item ID) .
Variable 2
  1. Position the insertion point after the equal sign (=) and then click Add or Change Lookup.
  1. In the Lookup for String dialogue box, select Current Item in the DataSource box and ID in the Field from source box.
Variable 3
  1. Click OK. The lookup is added to the text in the dialogue box.
Variable 4
  1. Click OK to close the String Builder dialogue box.
  1. 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.

  1. Select Variable: substring or Variable: substring 1 in Output to Variable: substring.
  1. In the list, click Create a new variable and then, in the Edit Variable dialogue box, type a name for the new variable.

  1. Make sure that Type is set to String, and then click OK
Variable 5
  1. 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
  1. To use the new variable in the Define E-mail Message dialogue 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.

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

  1. In the Fieldf rom 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.

  1. Click workflow variable and select Create a new variable

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

  1. 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
  1. Click OK.

  1. The inserted Action appears like this.
Setting Variable for inserting an image
  1. 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
  1. In the Define E-mail Message dialogue box, click Add or Change Lookup.

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

  1. In the Field from source list, select Variable: Name of Variable and select OK.
Email String in Image Workflow
Workflow Email Mesage body with Image
  1. 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.

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.

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 e-mail 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.

Leave a Reply

%d bloggers like this: