Reputation: 454
I'm new to ASP.NET with C#. Can anybody guide me on how to send an email through ASP.NET with C# using server (including configuring the server).
Upvotes: 1
Views: 977
Reputation: 28824
using System.Net.Mail;
...
MailMessage message = new MailMessage();
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.CC.Add(new MailAddress("[email protected]"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
in the web.config
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
</smtp>
</mailSettings>
Thanks Scott
Upvotes: 4