How do I fix System.Net.Mail.SmtException: 'Cannot get IIS pickup directory' error?
-
I am trying to send email using the EmailButton_Click code. However I am getting the error on this line smtp.Send(mailMessage) The error is System.Net.Mail.SmtpException: 'Cannot get IIS pickup directory.' Can someone help me fix it please?
protected void EmailButton_Click(object sender, EventArgs e)
{
//get selected email
EmailButton.Visible = true;
string requestor = RequestorDropDownList.SelectedValue.ToString();
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");
//Uncomment after testing in Deve June 2019
MailAddress to = new MailAddress(requestor);
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;
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mailMessage);//Error on this line
}
string msg = "No batches were found";
Response.Write("alert('" + msg + "')");
} -
I am trying to send email using the EmailButton_Click code. However I am getting the error on this line smtp.Send(mailMessage) The error is System.Net.Mail.SmtpException: 'Cannot get IIS pickup directory.' Can someone help me fix it please?
protected void EmailButton_Click(object sender, EventArgs e)
{
//get selected email
EmailButton.Visible = true;
string requestor = RequestorDropDownList.SelectedValue.ToString();
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");
//Uncomment after testing in Deve June 2019
MailAddress to = new MailAddress(requestor);
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;
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mailMessage);//Error on this line
}
string msg = "No batches were found";
Response.Write("alert('" + msg + "')");
}This is much the same issue as you posted a couple of days ago below at How to I make EmailButton_Click work? - ASP.NET Discussion Boards[^], and you appear to be trying to learn how to make it work by posting questions one at a time. Can i suggest that you study the SMTP documentation more closely to see exactly how you should be using these features. If you want to use
PickupDirectoryFromIis
then you most likely need to configure it within IIS. -
I am trying to send email using the EmailButton_Click code. However I am getting the error on this line smtp.Send(mailMessage) The error is System.Net.Mail.SmtpException: 'Cannot get IIS pickup directory.' Can someone help me fix it please?
protected void EmailButton_Click(object sender, EventArgs e)
{
//get selected email
EmailButton.Visible = true;
string requestor = RequestorDropDownList.SelectedValue.ToString();
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");
//Uncomment after testing in Deve June 2019
MailAddress to = new MailAddress(requestor);
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;
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mailMessage);//Error on this line
}
string msg = "No batches were found";
Response.Write("alert('" + msg + "')");
}First google result has some possible fixes, https://stackoverflow.com/questions/2190361/cannot-get-iis-pickup-directory
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.