Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the alternative to this line of code? 2

Status
Not open for further replies.

aspdotnetuser

Programmer
Oct 10, 2008
45
0
0
GB
Hi,

I am replacing all System.Web.Mail code with System.Net.Mail - everything works ok when I specify the host and port in the same code block as the email details, but if I want it to refer to the System.Net settings in web.config what do I need to replace the following line of code with?

[blue]SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["SmtpServer"].ToString();[/blue]
 
I don't understand the question. What do you mean replace the following code with? Just create an entry in your web.config that holds the name of the SmtpServer.
 
if you configure the settings in the web.config, all you need is a new smtpclient. These values would be stored in the system.net - mailsettings node, not the appsettings node
Code:
SmtpClient smtp = new SmtpClient();
smtp.Send(...);
check out for more information

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I realised I just have to include the settings in the web.config.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top