A sample code on how to send emails with .NET Framework 2.0 using C#. The code authenticates to a SMTP server and then sends an email to multiple recipients. It can easily be used in ASP.NET 2.0 websites.
Contextual Ads
More C# Resources
Advertisement
using System.Net.Mail;
System.Net.NetworkCredential crdSupport = new System.Net.NetworkCredential("[email protected]", "passwordHere");
SmtpClient smtpConfirmation = new SmtpClient("mail.geekpedia.com", 25);
smtpConfirmation.UseDefaultCredentials = true;
smtpConfirmation.Credentials = crdSupport;
mmConfirmation = new MailMessage();
mmConfirmation.From = new MailAddress("support@geekpedia", "Geekpedia Support");
mmConfirmation.To.Add("[email protected]");
mmConfirmation.To.Add("[email protected]");
mmConfirmation.Subject = "Message subject goes here";
mmConfirmation.Body = "Message body goes here";
smtpConfirmation.Send(mmConfirmation);
// For a tutorial on doing this with ASP.NET 1.1 see http://www.geekpedia.com/tutorial124_Sending-emails-with-ASP-.NET.html