HELP! -
I have a C# .net application that sends email primarily and it is no longer working. Its very basic but its a down application at this point. I need some assistance in getting this up quickly:
//NEW SALES LEAD EMAIL
public bool SendNewSalesLeadEmail(SaveSalesLeadModel CR)
{
try
{
string smtpSetting = ConfigurationManager.AppSettings["smtpserver"];
SmtpClient smtpClient = new SmtpClient(smtpSetting, 587);
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
string _subj = "Customer Service Request Call-Confirmation";
string appName = ConfigurationManager.AppSettings["AppName"];
string MailSend = ConfigurationManager.AppSettings["MailSend"];
if (MailSend.ToUpper() == "ON")
{
string smtpemailFromName = ConfigurationManager.AppSettings["emailFromName"];
string smtpemailFromPwd = ConfigurationManager.AppSettings["emailFromPwd"];
string smtpemailAlias = ConfigurationManager.AppSettings["emailFromAlias"];
string smtpPort = ConfigurationManager.AppSettings["smtpPort"];
string currentEnv = ConfigurationManager.AppSettings["currentEnv"];
smtpClient.Credentials = new System.Net.NetworkCredential(smtpemailFromName, smtpemailFromPwd);
//smtpClient.UseDefaultCredentials = true; // uncomment if you don't want to use the network credentials
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
//Setting From , To and CC
mail.From = new MailAddress(smtpemailFromName, smtpemailAlias);
// mail.To.Add(new MailAddress("email address removed for privacy reasons", "Utz Customer Service Request-Admin"));
//mail.To.Add(new MailAddress("email address removed for privacy reasons", "Utz Customer Service Request-Admin"));
//PopulateSalesLeadRecipients(mail, CR, "1");
//mail.To.Add(new MailAddress(Sendto));
//mail.To.Add(HttpContext.Current.User.Identity.Name.ToString());
mail.Subject = "New Sales Lead";
mail.IsBodyHtml = true;
string sBody = "";
sBody = "<html>";
sBody = sBody + "<head>";
sBody = sBody + "<meta charset = 'utf-8' />";
sBody = sBody + "<title></title>";
sBody = sBody + "</head>";
sBody = sBody + "<body style = 'background-color:white; font-family: 'Times New Roman';>";
sBody = sBody + "<div style = 'color:black;'>";
sBody = sBody + "<table style = 'border:3px solid black; width:100%; text-align:center;'>";
sBody = sBody + "<tr style = 'background-color:white; color:black;'>";
sBody = sBody + "<td style = 'border-right:none;'>";
sBody = sBody + "<img src='https://Customer.utzsnacks.com/Content/Images/Utz2_Trans_180x.png'/>";
sBody = sBody + "</td>";
sBody = sBody + "<td style = 'vertical-align:middle;border-left:none;font-size:26px;color:#022a68;'>Utz Quality Foods<br/><font color='red'> Sales Lead</font></td>";
sBody = sBody + "</tr>";
sBody = sBody + "</table>";
sBody = sBody + "</div>";
sBody = sBody + "<div style = 'color:black; font-family:'Times New Roman'''>";
sBody = sBody + "<table>";
sBody = sBody + "<tr>";
sBody = sBody + "<td style = 'padding-right:50px;'>";
sBody = sBody + "<div>A Sales lead has been generated for your region via the Customer Service Request system. It has been forwarded to you based on region information known to our CSR. If this prospective customer isn't in your region please forward the lead to the proper representative.</div>";
sBody = sBody + "<table>";
sBody = sBody + "<tr>";
sBody = sBody + "<th style = 'color:black;text-align:right;'>Customer Name:</th>";
sBody = sBody + "<td>" + CR.thisSalesLead.CustomerName + "</td>";
sBody = sBody + "</tr>";
sBody = sBody + "<tr>";
sBody = sBody + "<th style = 'color:black; text-align:right;'>Address:</th>";
sBody = sBody + "<td>" + CR.thisSalesLead.CustomerStreetAddr + "</td>";
sBody = sBody + "</tr>";
sBody = sBody + "<tr>";
sBody = sBody + "<th style = 'color:black; text-align:right;'>City/State/ZipCode</th>";
sBody = sBody + "<td>" + CR.thisSalesLead.CustomerCity + ", " + CR.thisSalesLead.CustomerState + " " + CR.thisSalesLead.CustomerZipCode + "</td>";
sBody = sBody + "</tr>";
sBody = sBody + "<tr>";
sBody = sBody + "<th style = 'color:black; text-align:right;'>Contact Phone</th>";
sBody = sBody + "<td>" + CR.thisSalesLead.CustomerContactPhn + "</td>";
sBody = sBody + "</tr>";
sBody = sBody + "<tr>";
sBody = sBody + "<th style = 'color:black; text-align:right;'>Contact Name:</th>";
sBody = sBody + "<td>" + CR.thisSalesLead.CustomerContactName + "</td>";
sBody = sBody + "</tr>";
sBody = sBody + "<tr>";
sBody = sBody + "<th style = 'color:black; text-align:right;'>Contact Email:</th>";
sBody = sBody + "<td>" + CR.thisSalesLead.CustomerEmail + "</td>";
sBody = sBody + "</tr>";
sBody = sBody + "<tr>";
sBody = sBody + "<th style = 'color:black; text-align:right;'>Notes:</th>";
sBody = sBody + "<td>" + CR.thisSalesLead.LeadNotes + "</td>";
sBody = sBody + "</tr>";
sBody = sBody + "</table></td></tr></table>";
string MailSendMode = ConfigurationManager.AppSettings["MailSendMode"];
if (MailSendMode.ToUpper() == "TEST")
{
sBody = sBody + "<div>";
sBody = sBody + "<p>We are currently in test mode. If we were in production mode the following people would have gotten this email:</p>";
sBody = sBody + "<table>";
System.Net.Mail.MailMessage MB = new System.Net.Mail.MailMessage();
//PopulateSalesLeadRecipients(mail, CR, "99");
//MB.To.Add(Sendto);
foreach (UtzEmailRecip MA in CR.SendTo)
{
sBody = sBody + "<tr><td>" + MA.Display.ToString() + "</td><td>" + MA.Email.ToString() + "</td></tr>";
}
sBody = sBody + "</table>";
}
else
{
//PopulateSalesLeadRecipients(mail, CR, "99");
foreach (UtzEmailRecip MA in CR.SendTo)
{
if (!EmailExists(mail, MA.Email.ToString()))
{
mail.To.Add(new MailAddress(MA.Email, MA.Display));
}
}
}
sBody = sBody + "</body></html>";
mail.CC.Add(new MailAddress("email address removed for privacy reasons", "Dan Colgan"));
mail.CC.Add(new MailAddress("email address removed for privacy reasons", "Ashley Burkes"));
mail.Body = sBody;
smtpClient.Send(mail);
return true;
}
else
{
return true;
}
}
catch (SmtpException mailErr)
{
//Log it... then continue..
utzCommon.recordWebApiProcess(ConfigurationManager.AppSettings["AppName"], "/api/database/SendMail", "error", "Error sending sysMsg", "SendMail", mailErr);
return true;
}
}
#endregion
I need step by step instructions to get this up and running with Modern Authentication as the app is production and it is down.