Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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).

share|improve this answer
    
Could you expand on "... with a little manual copying you can deploy them in a sandbox solution yourself as well."? –  mbreske Jul 19 '11 at 23:05
2  
When you save a SharePoint Designer workflow as a template, it creates a WSP that can be uploaded into the Solution Gallery of a Site Collection (Sandboxed Solution). WSP files are just .CAB files. Save the workflow as a Site Template, rename the .WSP to a .CAB and you will see it is just a normal WSP with a Manifest, Feature.Xml, Elements, etc. Copy the files into your own VS2010 sandbox solution project to mix and match with your own additional elements. –  Chris Beckett Jul 20 '11 at 0:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.