Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
When using this class how come the examples I see on the internet do not include statements for port number, username and password, and servername?

I'm going to be using this class on a client app and I think I need to supply this information but do not know how to code it.
Posted

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient([Host], [Port]);<br />smtp.Credentials = new System.Net.NetworkCredential([UserName], [Password]);

If you prefer, use the config file (web.config, app.config).
<system.net&gt<br />	<mailSettings><br />		<smtp><br />			<network host="" port="" userName="" password="" /><br />		</smtp><br />	</mailSettings><br />&lt/system.net>
 
Share this answer
 
I have seen many that give examples, but they wont give you real working one.

See here[^] and here[^] for code examples

 
Share this answer
 
You need to use System.Net.Mail.SmtpClient[^] and then SmtpClient.Credentials[^].

Simple credential:
client.Credentials = new System.Net.NetworkCredential(username, password);


 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900