System.Net.Mail setup
-
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.
-
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.
You need to use System.Net.Mail.SmtpClient[^] and then SmtpClient.Credentials[^]. Simple credential:
client.Credentials = new System.Net.NetworkCredential(username, password);
hmmm pie
-
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.
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient([Host], [Port]);
smtp.Credentials = new System.Net.NetworkCredential([UserName], [Password]);If you prefer, use the config file (web.config, app.config).
<system.net>
<mailSettings>
<smtp>
<network host="" port="" userName="" password="" />
</smtp>
</mailSettings>
</system.net> -
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.
-
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.
System.Net.Mail is not a class, but is a namespace. Documentation...[^]
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -