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
            }
        }

No comments:

Post a Comment