I’m trying to send an email from my website that I’ve upgraded from .NET 1.1 to 2.0. The 1.1 version set the SmtpServer like this:
System.Web.Mail.SmtpMail.SmtpServer = Current.Application.Item("SMTPServer")
It’s using the SmtpMail.SmtpServer property from the old ‘System.Web.Mail’ namespace.
How do I set the SmtpServer without using any classes/properties from the old namespace? I’ve seen a couple of examples online that set the SmtpServer in the web.config file.
Is this the only way? How can you use an application setting in web.config ?
Use System.Net.Mail.SmtpClient.
You can also choose to set the server imperatively.