You can't specify the FROM address for email messages when you use the "Send an email" option from a SharePoint Designer 2013 workflow action

 

PROBLEM

When you create a SharePoint Designer 2013 Workflow and you use the Send an email action, you don't have the option to specify a FROM email address. This setting is pulled from the Outgoing Email settings in SharePoint 2013 on-premises Central Administration.

WORKAROUND

The SendEmail REST endpoint can be performed manually in a SharePoint Designer 2013 Workflow (also known as the SharePoint 2013 Workflow Platform) by using a valid SharePoint user's email address.
To understand what's being constructed, query the REST endpoint by using the SharePoint Designer Call HTTP Web Service Activity. Refer to the client-side object model (CSOM) documentation for more information. For more information, go to the following Microsoft website:

Utility.SendEmail method

This was performed on a SharePoint On-premise Site  
The following steps are used to re-create a parameterized version of what the Send an Email action does. Here's a sample JavaScript Object Notation (JSON) object sent by Workflow Manager to SharePoint 2013 by using the SharePoint REST endpoint:

{

"properties": {

"To": {

"results": ["i:0#.w|contoso\\validUser", "i:0#.w|contoso\\validUser2", "SharePoint Owner Group"]

},

"Subject": "HI",

"From": "validSPUser@contoso.com",

"__metadata": {

"type": "SP.Utilities.EmailProperties"

},

"Body": "<HTML><HEAD> <META name=GENERATOR content=\"MSHTML 10.00.9200.16843\"><\/HEAD>

<BODY> <P><FONT color=#00ff00 size=6 face=\"Segoe UI\"><STRONG><A href=\"Lists\/groups\/1_.000\">abc<\/A>

<\/STRONG><\/FONT><\/P><\/BODY><\/HTML>"

}

}

  1. Connect to a site by using SharePoint Designer 2013.
  2. Click Workflows, and then click Site Workflows.
  3. Give the workflow a name, and then select SharePoint 2013 Workflow Platform.
  4. Right-click the transition to stage, and then click go to stage.
  5. Click End of Workflow.
  6. Type replace to insert the replace action, and then click the first string text.
  7. Type a semicolon (;), and then in the second string, type a comma (,).
  8. Click the third string and then click Fx. Select Workflow Context, click Initiator, and then select Login Name as the return type. If multiple selections are enabled, you'll want to use the Login Names, Semicolon Delimited option.
    • This is an unnecessary step for a SharePoint People/Group column that has a single value. However, if you do this, it's possible to send email messages without additional changes to the workflow.
    • The output of this Replace action will be sent to a new variable called output.
  1. Insert another Replace action. This time, click the first string and then type a backslash (\). In the second string, type two backslashes (\\).
    • Select the variable named output as the data source from the previous step, and then change the output to the same step.
    • Doing this encodes the backslash that's found in SharePoint claims. Other characters may also have to be escaped.
  1. Insert a set workflow variable action. Set the output variable to use the output variable and several additional characters.
    • It should resemble the following:

[“[%Variable: output%]”]

    • Take the current value, which could be a single claim, multiple claims or SharePoint groups, and add quotation marks (") and square braces ([]) around it. The replace actions from before took the semicolon character and replaced it with a comma (,) and encoded any backslashes (\) with two backslashes (\\). Review the JSON object at the beginning of these steps to compare the patter that's being created manually.
  1. In Stage 1 type build, click Enter. This inserts the build a dictionary action.
  2. Click the Variable:Dictionary, and then create a new variable named requestBody. Leave it as a Dictionary Type.
  3. Click this variable, and then click the Add button.
  4. Click this variable, and in the dictionary variable properties, create the following key and value pairs:

 

Name

Type

Value

properties/__metadata/type

String

SP.Utilities.EmailProperties

properties/Subject

String

Hello

properties/From

String

validSPUser@contoso.com

properties/Body

String

HTML String. This can be borrowed from a Send an Email action by right-clicking the action and then selecting properties and copying the HTML from the body. Any lookups that were performed will have to be redone.

properties/To/results

Dictionary

Perform a lookup by using the fx button, to the Workflow Variables and Parameters data source, select the output variable. The return type will be As Dictionary from JSON.

  1. Type build again, and then create another dictionary object. Create a new variable called requestheaders. The following key and value pairs have to be created:

Name

Type

Value

Accept

String

application/json; odata=verbose

Content-Type

String

application/json; odata=verbose

 

  1. Type Call, and then add the Call HTTP Web Service Action to the workflow.
  2. Click the workflow, and then in the dialog box, click the ellipses (...)
  3. Click Add or change lookup, click Workflow Context, click Current Site URL, and then click OK.
  4. After the lookup, type /_vti_bin/client.svc/sp.utilities.utility.SendEmail. It should resemble the following:

[%Workflow Context:Current Site URL%]/_vti_bin/client.svc/sp.utilities.utility.SendEmail

  1. Change HTTP Verb to HTTP POST, and then click OK.
  2. Click request, and then select the responseBody dictionary variable.
  3. Right-click Call HTTP Web Service Action and then click Properties. In the dialog box, select the RequestHeaders drop-down and thenspecify the requestHeaders variable. Click OK.
  4. Click Publish.
  5. Browse to /_layouts/15/start.aspx#/_layouts/15/workflow.aspx. The site workflow should be listed and when you the workflow name, it should send an email message that contains a custom FROM address.

MORE INFORMATION

Note These steps can be performed with a list or a reusable workflow. 
The FROM address has to be associated with a valid user in SharePoint.
The TO addresses also have to be valid SharePoint users. The same rules apply as if we used the Send an Email Action in SharePoint Designer 2013 on the SharePoint 2013 Workflow Platform.
The Call HTTP Web Service Action can be configured to output various data such as headers, response code, and response body. If a multiline column is created, the output of these variables can be written there. The log to history list isn't suitable as the response can be larger than 255 characters.

Note: This article is relevant to On-Premise version of SharePoint 2013

POST BY : Dalibor Kovacevic [MSFT]