Have you ever tried to send an email in a SharePoint 2013 sandbox solution and it just won’t let you? This is because it simply is not possible to send an e-mail directly through code because the functionality to do this is expressly disallowed. But here at Evoke IT we are all about helping out so here is a solution. And guess what; it’s easy…..!!
STEP 1: Create the list.
This should contain fields for data such as To, Subject, and Body.
STEP 2: Create a list workflow.
Top tip: This should be done through SharePoint Designer 2013 as opposed to the web based interface (as it won’t allow you the same functionality). The following screenshots are from SharePoint 2010 workflow but by following the steps, the same result can be achieved on SharePoint 2013 workflow.
It requires the action to send the email, but you can add a second action to delete the list item if you want or need to. Configure the command to take its data from the current list item as shown, then save and publish it.
STEP 3: Make sure that the workflow is set to start when a list item is created.
STEP 4: Test what you have done so far by adding a list item through the browser interface. At this stage, the e-mail should be sent through to you.
STEP 5: Write and test the code to add a list item to the list. Once the item is saved, the workflow should pick it up and e-mail it through.
And ta-daah! You can send email in a SharePoint 2013 sandbox solution. So to summarise… All you need to do is save your e-mail to a list item and create a workflow to send an e-mail on creation of a list item in that list. For more information you can learn more about SharePoint 2019.
If you want some local help we have SharePoint Developers In Edinburgh and Aberdeen.