Total Pageviews

15 Jan 2014

Send Email with HTML Link to the Current User with SPUtility.SendEmail


Code:
        private void SendEmailWithReportLink(SPWeb web)
        {
            string bodyText = "To see the report <a href='" + "/_layouts/report.aspx" + "'>click here</a>. <br>";
            Boolean emailSent = true;
            SPSecurity.RunWithElevatedPrivileges(delegate() { 
                emailSent = SPUtility.SendEmail(web, true,false, SPContext.Current.Web.CurrentUser.Email,
                    "Report «Quality Control Summary» is ready", bodyText, true);
            
            });

            if (emailSent)
            {
               //TODO: log message
            }
            else
            {
                //TODO: log error
            }
        }

1 comment:

  1. Nice Article ! amazing that such a short, to-the-point list could be so useful and clear. It’s like the info. SharePoint den

    ReplyDelete