Thursday, 12 February 2015

SharePoint 2013: Sending Mail in SharePoint using SPUtility

Sending Mail in SharePoint using SPUtility Method:

If you want to send a mail from SharePoint from server side. use below function:

            StringDictionary headers = new StringDictionary();
            headers.Add("to", strTo);
            headers.Add("cc", strCC);
            headers.Add("bcc", strbcc);
            headers.Add("from", strFrom);
            headers.Add("subject", strSubject);
            headers.Add("content-type", "text/html");
            StringBuilder mailbody = new StringBuilder();
            mailbody.AppendLine("The following request has been assigned to you:<br/>");
            mailbody.AppendLine("<br/>");
            mailbody.AppendLine("clicking on the following link: <a href='" + Link + "'>" + Request Name + "</a><br/>");
            SPUtility.SendEmail(web, headers, mailbody);

No comments:

Post a Comment