I keep getting the "Cannot get IIS pickup directory." error. The only fix I've seen on the forum is make sure Host is set to "localhost", but I'm still getting the error. Any help would be appreciated. Here's the code: MailMessage msg = new MailMessage(); msg.IsBodyHtml = false; msg.BodyEncoding = Encoding.Default; msg.From = new MailAddress("[email protected]"); msg.To.Add(new MailAddress("[email protected]")); msg.Subject = "test"; msg.Body = "test"; SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = "localhost"; smtpClient.Send(msg);
Make sure you are not specifying the pickup directory anywhere else.You can also set the following property in your code: smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; Vikram DiscountASP.NET www.DiscountASP.NET
I added the line smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; and now it works. Thank you.