Thursday, July 24, 2008

How to use built-in SharePoint 2007 engine to send email?

A straightforward way of sending email from within a SharePoint 2007 application is to use the Object Model. Here is some C# code that will do it for you:


bool isAppendHtmlTag = true;
bool isHtmlEncode = false;
string recipient = "whoever@whatever.com";
string title = "This is the title";
string body = "This is the email <strong>body</strong>";

Microsoft.SharePoint.Utilities.SPUtility.SendEmail(
Microsoft.SharePoint.SPContext.Current.Web,
isAppendHtmlTag,
isHtmlEncode,
recipient,title,
body);

No comments:

Post a Comment