Send Email using Server Side
Sending Email in Server Side
public void EmailSendApprovers(SPSite osite, SPWeb oweb, SPListItem oitem, string nextapprovers, string NewID, string Requestor, string key, string msgsubject)
{
using (SPSite newsite = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb newweb = newsite.OpenWeb())
{
try
{
SPPrincipalInfo pinfo = SPUtility.ResolvePrincipal(oweb, nextapprovers, SPPrincipalType.User, SPPrincipalSource.All, oweb.AllUsers, false);
string Copyto = string.Empty;
string Subject = string.Empty;
string htmlBody = string.Empty;
string bcc = "nhr@hexacorp.com";
bool status = false;
Subject = Convert.ToString(oitem["NHRId"]) + " " + msgsubject;
string link = "Click on the Link";
string oSplitID = Convert.ToString(oitem["NHRId"]).Split('/')[2];
string docLink = "<a href=" + osite.Url + "/SitePages/NHRDisplayUS.aspx?ItemID=" + NewID + ">" + link + "</a>";
Copyto = "";
StringDictionary headers = new StringDictionary();
headers.Add("to", nextapprovers);
headers.Add("from", "NHR@hexacorp.com");
headers.Add("bcc", bcc);
headers.Add("subject", Subject);
headers.Add("content-type", "text/html");
htmlBody = "Call your Function / Simply set your text"
htmlBody = htmlBody + docLink;
status = Microsoft.SharePoint.Utilities.SPUtility.SendEmail(oweb, headers, htmlBody.ToString());
}
catch (Exception ex)
{ }
}
}
}
public void EmailSendApprovers(SPSite osite, SPWeb oweb, SPListItem oitem, string nextapprovers, string NewID, string Requestor, string key, string msgsubject)
{
using (SPSite newsite = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb newweb = newsite.OpenWeb())
{
try
{
SPPrincipalInfo pinfo = SPUtility.ResolvePrincipal(oweb, nextapprovers, SPPrincipalType.User, SPPrincipalSource.All, oweb.AllUsers, false);
string Copyto = string.Empty;
string Subject = string.Empty;
string htmlBody = string.Empty;
string bcc = "nhr@hexacorp.com";
bool status = false;
Subject = Convert.ToString(oitem["NHRId"]) + " " + msgsubject;
string link = "Click on the Link";
string oSplitID = Convert.ToString(oitem["NHRId"]).Split('/')[2];
string docLink = "<a href=" + osite.Url + "/SitePages/NHRDisplayUS.aspx?ItemID=" + NewID + ">" + link + "</a>";
Copyto = "";
StringDictionary headers = new StringDictionary();
headers.Add("to", nextapprovers);
headers.Add("from", "NHR@hexacorp.com");
headers.Add("bcc", bcc);
headers.Add("subject", Subject);
headers.Add("content-type", "text/html");
htmlBody = "Call your Function / Simply set your text"
htmlBody = htmlBody + docLink;
status = Microsoft.SharePoint.Utilities.SPUtility.SendEmail(oweb, headers, htmlBody.ToString());
}
catch (Exception ex)
{ }
}
}
}

Comments
Post a Comment