sending Mails when Task is Created to a User
SPTaskProperties.ExtendedProperties["WorkflowStatusUrl"] = SPTaskProperties12.SiteUrl + "//" + SPTaskProperties12.Workflow.StatusUrl;
relatedcontenturl = SPTaskProperties12.SiteUrl + "//" + SPTaskProperties12.Workflow.StatusUrl;
Mails(TaskAssignedTo, relatedcontenturl);
public void Mails(string TaskAssignedTo, string relatedcontenturl)
{
StringDictionary headers = new StringDictionary();
//headers.Add("to",
try
{
using (SPWeb webs = SPTaskProperties12.Web)
{
////bool IsBodyHtml = true;
string Body=string.Empty;
string to = string.Empty;
string ESubject = string.Empty;
string relatedcontentstring = "Click here";
SPList lst = SPTaskProperties12.Web.Lists["KaizenMailDetails"];
SPListItem lstitem = lst.GetItemById(7);
if(lstitem["BodyText"]!=null)
Body = lstitem["BodyText"].ToString();
if (lstitem["Subject"] != null)
ESubject = lstitem["Subject"].ToString();
//// SPListItem lstItem = GetMailListDetails("KaizenMailDetails", mailType);
SPUser Touser = webs.EnsureUser(TaskAssignedTo);
to = Touser.Email;
headers.Add("to", to);
//headers.Add("cc", cc);
headers.Add("subject", ESubject);
string bodyText = "Dear " + Touser.Name + ",</br></br>";/////With Comments:</br>'" + Acomments + "'.<br/></br> Please Review '" + Filename + "' "
string body = bodyText + Body;
body = body + " To view the item <a href='" + relatedcontenturl + "'>" + relatedcontentstring + "</a></br></br>";
//string link = SPTaskProperties12.SiteUrl + "//" + SPTaskProperties12.Workflow.StatusUrl;
SPUtility.SendEmail(webs, headers, body);
}
}
catch (Exception ex)
{
}
}
Comments