none
SharePoint Rest API In Javascript RRS feed

  • Question


  • I have the code your created in the above. Very nice. I work for one of your customers Wells Fargo. The Sp Requirements I received seems to be feel its important to change The FROM  SP email that's sent out to SP Users.  Normally this uses whatever central admin enter as the server addres and inlcude do not reply in the FROM.

     

    Requirements:

    1. Step1 -Desire SP Emails From  to =  TREX Reporting @WellsFargo.com .............minus the do not reply.
    2. Step2 The Recipients or To of the email needs filter a list and fetch created by email user names if status= yes. If yes then extract the createdby email names and insert them into the To Variable
    3. In the Body: We already have some html code in a file called  filename.html

     

    Question

    How to Change the code in the above link accommodate 1,2,3

    Email Contact: xxx@xxx,com 

     

    Joe Mezzo

     




    Thursday, November 14, 2019 5:12 AM

Answers

  • Hi JoeMezzoJr,

    I have tested this scenario and it works fine here. please take a reference of the following steps:


    1, Create 2 lists: testWF and subscribe. The former one is associated with our workflow and the second list contains the recipients。

    2, Create a list workflow, add the following stage 

    In this stage, we will query items of which status is 'yes' and get their Author name. The actual request is :

    Method : Get 

    Endpoint :  {siteurl}/_api/web/lists/getbytitle('subscribe')/items?$filter=status eq 1&$select=Title,Author/ID,Author/Name&$expand=Author

    You could refer to below blog to get more details about how to do an HTTP call in a workflow:

    3, Prepare payload for sending email request 

    In this stage, we loop the item collections and get Author name (like : i:0#.w|contoso\\wft02 ). 

    tmpStr is the value of 'To' filed: 

    4, Follow the same method described in the blog you provided to generate the completed payload:

    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.

    Workflow log :

    5, Send email 

    And the behind request URL is : 

    Method:  post

    Endpoint: {site}/_api/sp.utilities.utility.SendEmail

    Payload: 

    {
      "properties": {
        "To": {
          "results": [
            "i:0#.w|contoso\\wft02",
            "i:0#.w|contoso\\wft03"
          ]
        },
        "Subject": "subject",
        "From": "wft01@contoso.com",
        "__metadata": {
          "type": "SP.Utilities.EmailProperties"
        },
        "Body": "body"
      }
    }

    6, Publish the workflow. You can have a look my test result (it's a gif file).

    Hope above helps and please feel free to talk with us if you need further assistance.

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by JoeMezzoJr Wednesday, November 20, 2019 10:22 PM
    Wednesday, November 20, 2019 9:06 AM

All replies

  • Hi Joe,

    The URL you provided navigates me to the following page : 

    Could you please share the code again? Also may i know more background info?

    * Please Do not expose any sensitive information such as personal email as this is a public forum.

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.


    Thursday, November 14, 2019 7:04 AM
  • See this link :http://blogs.msdn.com/b/spses/archive/2014/10/24/you-can-t-specify-the-from-address-for-email-messages-when-you-use-the-quot-send-an-email-quot-option-from-a-sharepoint-designer-2013-workflow-action.aspx

    Had this working at one point. But this code does not seem to work in a List Workflow versus the above which was created using a site workflow. Does not matter if it has to remain as a site workflow. We are not allowed to touch central admin at our work site to add features, software, etc. .

    Objective: Change the From address in an email from Sharepoint server name to TREXReporting@wellsfargo.com

    The recipients of this email are filtered from an subscriber list. If the subscriber list column "Status" equals "yes", grab the createdBy(Author) of the list item and include these names in the Sharepoint Workffow email "To:" in the email. So Again the requirements:

    Requirements:

    1. Step1 -SP WorkFlow Email From  Changed to =  TREX Reporting @WellsFargo.comfrom  .............current from is from site admin address.
    2. Step2: The Recipients or To of the email needs to get the names from a subscriber list. Fetch createdby email on user names in this list if status= yes.  Maybe store them in a Workflow varible.
    3. In the Body: We already have html code that looks good and contains links. If was created by getting previous Workflow email (right click properties) and copy the body html. Its stored in  "filename.html".

    I hope this helps. My direct email at work is Joseph.a.mezzo@wellsfargo.com/ My personaL email is JoeMezzoJr@gmail.com. I am behind schedule on making this happen.

    Friday, November 15, 2019 12:29 PM
  • Hi JoeMezzoJr,

    Although we can change the value of 'From' Field to a custom email address. The received emails will still be sent from no-reply address as these are outgoing emails (only the display name will be changed). To configure the outgoing email address, please take a reference of the following doc:

    In this case, the whole farm will be affected including the current workflow. 

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.


    Monday, November 18, 2019 9:45 AM
  • Albeit that solution requires one to be a SharePoint administrator and to be using 2019 with SMTP.
    See this link :http://blogs.msdn.com/b/spses/archive/2014/10/24/you-can-t-specify-the-from-address-for-email-messages-when-you-use-the-quot-send-an-email-quot-option-from-a-sharepoint-designer-2013-workflow-action.aspx

    This does not require admin or 2019.  Had it working last week. Albeit not right now.
     The current failure Response code shown in the log is "BadRequest" . Can someone fix  instructions so it will work again?

    Thanks

    Monday, November 18, 2019 6:02 PM
  • Hi JoeMezzoJr,

    I have tested this scenario and it works fine here. please take a reference of the following steps:


    1, Create 2 lists: testWF and subscribe. The former one is associated with our workflow and the second list contains the recipients。

    2, Create a list workflow, add the following stage 

    In this stage, we will query items of which status is 'yes' and get their Author name. The actual request is :

    Method : Get 

    Endpoint :  {siteurl}/_api/web/lists/getbytitle('subscribe')/items?$filter=status eq 1&$select=Title,Author/ID,Author/Name&$expand=Author

    You could refer to below blog to get more details about how to do an HTTP call in a workflow:

    3, Prepare payload for sending email request 

    In this stage, we loop the item collections and get Author name (like : i:0#.w|contoso\\wft02 ). 

    tmpStr is the value of 'To' filed: 

    4, Follow the same method described in the blog you provided to generate the completed payload:

    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.

    Workflow log :

    5, Send email 

    And the behind request URL is : 

    Method:  post

    Endpoint: {site}/_api/sp.utilities.utility.SendEmail

    Payload: 

    {
      "properties": {
        "To": {
          "results": [
            "i:0#.w|contoso\\wft02",
            "i:0#.w|contoso\\wft03"
          ]
        },
        "Subject": "subject",
        "From": "wft01@contoso.com",
        "__metadata": {
          "type": "SP.Utilities.EmailProperties"
        },
        "Body": "body"
      }
    }

    6, Publish the workflow. You can have a look my test result (it's a gif file).

    Hope above helps and please feel free to talk with us if you need further assistance.

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by JoeMezzoJr Wednesday, November 20, 2019 10:22 PM
    Wednesday, November 20, 2019 9:06 AM
  • Excellent work. Thank You for your reply.
    Wednesday, November 20, 2019 10:23 PM
  • Baker

    Question for you: Where does this Payload Go?

    { "properties": { "To": { "results": [ "i:0#.w|contoso\\wft02", "i:0#.w|contoso\\wft03" ] }, "Subject": "subject", "From": "wft01@contoso.com", "__metadata": { "type": "SP.Utilities.EmailProperties" }, "Body": "body" } }


    Wednesday, November 20, 2019 10:42 PM
  • Hi JoeMezzoJr,

    The first stage actually sends the following request : 

    In the second stage, we loop the result and get Author's name, then contact them into an Array ( ["i:0#.w|contoso\\wft02", "i:0#.w|contoso\\wft03"] ).  

    We build a dictionary with the payload :

    In the last stage, we actually invoke the following request to send email :

    Hope the above is clear and thanks for marking it as Answer.

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, November 21, 2019 6:34 AM