How to I make EmailButton_Click work?
-
My code for EmailButton_Click is not working. I am getting an error System.Net.Mail.SmtpException: 'SSL must not be enabled for pickup-directory delivery methods.' so email is not sent. How can I fix this? Here is the code
protected void EmailButton_Click(object sender, EventArgs e)
{
//get selected emailstring requestor = RequestorDropDownList.SelectedValue.ToString(); //string message = "The following records have been prepped for processing. Valid cases will be processed.{0}{1}{2}"; string message = "The following records have been prepped for processing. Valid cases will be processed."; if (requestor.Length > 0) message = string.Format(message); using (MailMessage mailMessage = new MailMessage()) { mailMessage.From = new MailAddress("NoReply\_FTA@courts.state.mn.us"); //MailAddress to = new MailAddress(requestorEmail); MailAddress to = new MailAddress("okaymy1112@gmail.com"); mailMessage.To.Add(to); string ccEmailAddress = "okaymy1112@mail.com"; if (ccEmailAddress.Length > 0) { MailAddress ccto = new MailAddress(ccEmailAddress); mailMessage.CC.Add(ccto); } mailMessage.Subject = "FTA Case Reset Notice"; mailMessage.Body = message; mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient(); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtpClient.PickupDirectoryLocation = @"c:\\smtp"; smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = true; smtpClient.Timeout = 60000; smtpClient.Send(mailMessage);//Error occurs on this line ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('An email has been sent to '" + requestorName + "');", true); }
-
My code for EmailButton_Click is not working. I am getting an error System.Net.Mail.SmtpException: 'SSL must not be enabled for pickup-directory delivery methods.' so email is not sent. How can I fix this? Here is the code
protected void EmailButton_Click(object sender, EventArgs e)
{
//get selected emailstring requestor = RequestorDropDownList.SelectedValue.ToString(); //string message = "The following records have been prepped for processing. Valid cases will be processed.{0}{1}{2}"; string message = "The following records have been prepped for processing. Valid cases will be processed."; if (requestor.Length > 0) message = string.Format(message); using (MailMessage mailMessage = new MailMessage()) { mailMessage.From = new MailAddress("NoReply\_FTA@courts.state.mn.us"); //MailAddress to = new MailAddress(requestorEmail); MailAddress to = new MailAddress("okaymy1112@gmail.com"); mailMessage.To.Add(to); string ccEmailAddress = "okaymy1112@mail.com"; if (ccEmailAddress.Length > 0) { MailAddress ccto = new MailAddress(ccEmailAddress); mailMessage.CC.Add(ccto); } mailMessage.Subject = "FTA Case Reset Notice"; mailMessage.Body = message; mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient(); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtpClient.PickupDirectoryLocation = @"c:\\smtp"; smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = true; smtpClient.Timeout = 60000; smtpClient.Send(mailMessage);//Error occurs on this line ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('An email has been sent to '" + requestorName + "');", true); }
All you have to do is google the error if you do not understand what the error is telling you. My first google result has an option that fixed it for a particular user, smtpclient - getting the error: SSL must not be enabled for pickup-directory delivery methods - Stack Overflow[^]
Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.
-
My code for EmailButton_Click is not working. I am getting an error System.Net.Mail.SmtpException: 'SSL must not be enabled for pickup-directory delivery methods.' so email is not sent. How can I fix this? Here is the code
protected void EmailButton_Click(object sender, EventArgs e)
{
//get selected emailstring requestor = RequestorDropDownList.SelectedValue.ToString(); //string message = "The following records have been prepped for processing. Valid cases will be processed.{0}{1}{2}"; string message = "The following records have been prepped for processing. Valid cases will be processed."; if (requestor.Length > 0) message = string.Format(message); using (MailMessage mailMessage = new MailMessage()) { mailMessage.From = new MailAddress("NoReply\_FTA@courts.state.mn.us"); //MailAddress to = new MailAddress(requestorEmail); MailAddress to = new MailAddress("okaymy1112@gmail.com"); mailMessage.To.Add(to); string ccEmailAddress = "okaymy1112@mail.com"; if (ccEmailAddress.Length > 0) { MailAddress ccto = new MailAddress(ccEmailAddress); mailMessage.CC.Add(ccto); } mailMessage.Subject = "FTA Case Reset Notice"; mailMessage.Body = message; mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient(); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtpClient.PickupDirectoryLocation = @"c:\\smtp"; smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = true; smtpClient.Timeout = 60000; smtpClient.Send(mailMessage);//Error occurs on this line ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('An email has been sent to '" + requestorName + "');", true); }
The error is self-explanatory. You are using both SSL and a pickup folder, you can't use both. You either send over the network and use SSL, or write to the pickup folder which has no support for SSL. If you want to use the pickup folder don't set EnableSsl to true.
-
The error is self-explanatory. You are using both SSL and a pickup folder, you can't use both. You either send over the network and use SSL, or write to the pickup folder which has no support for SSL. If you want to use the pickup folder don't set EnableSsl to true.
Can you kindly help or guide me on doing it the way you described? For example based on my code how can I can it so that 1. I can send email over the network and use SSL or 2. write to the pickup folder which has no support for SSL
-
Can you kindly help or guide me on doing it the way you described? For example based on my code how can I can it so that 1. I can send email over the network and use SSL or 2. write to the pickup folder which has no support for SSL
The solution depends on if you want to use the pick-up folder or send over the network, something you haven't indicated.