//Send email of course cancellation
StoredProcConnect sprocRoster = new StoredProcConnect("sp_GetRosterByCourseID");
sprocRoster.AddParameters("COURSEID");
sprocRoster.AddValues(id);
DataSet ds = sprocRoster.Select();
if (ds == null)
Response.Redirect("ErrorMsg.aspx?error=Problem Getting Roster Info. Tech team has been notified, please try again");
MailAddressCollection coll = new MailAddressCollection();
if (ds.Tables[0].Rows.Count > 0)
{
string To = string.Empty;
foreach (DataRow row in ds.Tables[0].Rows)
{
msg.To.Add(row["email"].ToString() + "@COMPANY.com");
To = (row["email"].ToString() + "@COMPANY.com");
}
//toAddress = new Array(To);
coll.Add(To);
msg.From = new MailAddress("ClassChange@allstate.com");
msg.Subject = "An update to " + courseName + " has been made!";
// SendEmail();
if (chkCourseName.Checked == true)
{
var Body = this.PopulateBody(courseName,
courseName + " Has been changed!",
"A new entry will be sent to your Outlook Calendar."
+ "Please remove the old entry and accept the new entry." + name, "Sorry for any inconvenience that this change may have occured. " + "<br/>" + lblPresenter + "<br/>");
this.SendHtmlFormattedEmail(To, "An update to " + courseName + " has been made!", Body);
}
}
private string PopulateBody(string courseName, string title, string url, string description)
{
string body = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/HtmlPage1.html")))
{
body = reader.ReadToEnd();
}
body = body.Replace("{UserName}", courseName);
body = body.Replace("{Title}", title);
body = body.Replace("{Url}", url);
body = body.Replace("{Description}", description);
return body;
}
private void SendHtmlFormattedEmail(string recepientEmail, string subject, string Body)
{
using (MailMessage mailMessage = new MailMessage())
{
mailMessage.From = new MailAddress("Responses@COMPANY.com");
mailMessage.Subject = subject;
mailMessage.Body = Body;
mailMessage.IsBodyHtml = true;
mailMessage.To.Add(new MailAddress(recepientEmail));
Smtp info goes here
}
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.