Deprecated: Implicit conversion from float 1.1818181818181819 to int loses precision in /var/www/wp-content/mu-plugins/wp-login.php on line 13

Deprecated: Implicit conversion from float 1.074074074074074 to int loses precision in /var/www/wp-content/mu-plugins/wp-login.php on line 13

Deprecated: Implicit conversion from float 1.1818181818181819 to int loses precision in /var/www/wp-content/mu-plugins/wp-login.php on line 13
Send Email to Multiple Users using SharePoint Hosted App and Workflow – ridhvi.in
Close

Send Email to Multiple Users using SharePoint Hosted App and Workflow

Walk through : Building a workflow to send email message to Multiple users

Sending Email to Multiple users is always tricky as there is no Straight forward approach provided through Visual Studio Workflow like of SP Designer workflow. Below steps will achieve the functionality to send email to multiple  users that exist in a field of an item in a list.

If you want to try a simple workflow application which can send an email to a single user, below is the article which can help you.

https://blogs.msdn.microsoft.com/officeapps/2013/09/18/step-by-step-sending-email-messages-from-a-workflow-in-an-app-for-sharepoint-2013/

Now, let’s get started with multiple email addresses in the context of SharePoint.

A user manually triggers the workflow, which then sends an email message to the users in the one of the list field and adds a record in the workflow history that it has sent the email message.

  1. Create a SharePoint Hosted App
  2. Create a Sample List > Create a Field with Multi user option enabled.  To enable Multi User, you have to manually edit the List schema and provide attribute Multi = true. 
  3. This list will be used for maintaining the Users
  4. Create a Workflow from the New Items
  5. Give it a name and Select List workflow for the type
  6. Create a Sequence and name it Get Current Item Id. Idea is to get the users in the Attendees field for the current Item and send a test email
  7. Get the current Site url from the Workflow Context properties. To store this url, create a variable and store 
  8. Now create another variable as “RestApiUrl” and construct rest query by concatenating site url. your query would be looking like 
  9. Drag HTTPSend Activity from the toolbox and construct the parameters for sending the rest query
  10. Capture the User results like the one shown below in properties
  11. Count the User collection and store in an another variable
  12. Next step would be, check the count and introduce IF condition
  13. I have developed a separate custom activity called “Send Email to Users”.
  14. Create variables “Index” of type Int32 & “UsersEmailCollection” of type  “System.Collections.ObjectModel.Collection<System.String>”.
  15. Assign Index and Initiate UsersEmailCollection as they will be used in the While loop ahead
  16. Drag Do While Activity from the toolbox
  17. Drag TryCatch Activity and place it in Do While
  18. Drag GetDynamicValueProperty and place it in TryCatch
  19. In the properties of “GetDynamicValueProperty “, construct the pattern inorder to fetch the Individual user email id from the passed UserCollection. Create a variable UserId and place resuslt to this variable
  20. Now drag “LookUpUserActivity” from the toolbox and retrieve email for the user
  21. Drag “AddtoCollection” activity of type String
  22. In the properties of AddToCollection, provide the required parameters
  23. In the Catch and Condition, provide the necessary like below
  24. Now going back to the Main Workflow, drag Email Activity and provide the Email Collection
  25. Deploy and trigger the workflow
© 2024 ridhvi.in | WordPress Theme: Annina Free by CrestaProject.