Question

I have been tasked with creating a SharePoint 2010 sandboxed workflow that essentially scans a custom list and sends emails to specific users when certain conditions for a given list item are true. It would be straightforward to use the method below to send the emails.

SPUtility.SendEmail(SPWeb, StringDictionary, String)

However, that method is blocked in sandboxed workflows. I have read that it is possible to start a declarative SharePoint Designer workflow (like the one that sends an email) programmatically, but I am unable to find a good step by step explanation on how this is done. Note the users I am sending emails to are dynamic, so I will need a parameterized solution. Thoughts?

Was it helpful?

Solution

Why don't you just use the Send Email workflow action from SharePoint Designer? If you save a SharePoint Designer workflow as a template, the WSP is a sandbox solution, and with a little manual copying you can deploy them in a sandbox solution yourself as well.

If you must send email from a custom workflow action, then you need to use the System.Net.Mail ASP.NET mail object, you can't use the SharePoint one. The only caveat is that you need to store and set the address of the SMTP service yourself (the SharePoint SPUtility automatically use the SMTP server configured in outgoing email settings).

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top