The SPUtility.SendEmail method enables you to send an email from the context of a SharePoint Web (SPWeb) object. The SMTP settings associated with the SPWeb object are used to send the email. The method returns a boolean value that represents whether the email was sent successfully.
SPUtility.SendEmail Method (Microsoft.SharePoint.Utilities)
SPUtility.SendEmail (SPWeb, Boolean, Boolean, String, String, String)
example:
try
{
SPWeb thisWeb = SPControl.GetContextWeb(Context);
string toField = "mailaddress@microsoft.com";
string subject = "Test Message";
string body = "Message sent from SharePoint";
bool success = SPUtility.SendEmail(thisWeb,true, true, toField, subject, body);
}
catch (Exception ex)
{
// handle exception
}
3 comments:
Is there any way to put this into a workflow generated with SPD? Where should this code snipet be placed?
I have used this in custom workflows in visual studio not in SPD. sorry i haven't used that in SPD.
how do you send an email using custom workflow, genereated in visual studio to send email to a sharepoint group?
Post a Comment