Configuring SMTP in .Net
One of the easiest way to configure a mail service on .NET site is to create a SMTP class and call its function SendMail.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;public static class SMTP
{
public static void SendMail(string sFrom, string sTo, string sCC, string sSubject,
string sBODY, bool IsBodyHTML, string sHostName, string sAttachment)
{
try
{
MailMessage message = new MailMessage();
MailAddress address = new MailAddress(sFrom);
message.From = address;
message.To.Add(sTo);
if (sCC != string.Empty)
message.CC.Add(sCC);
message.IsBodyHtml = IsBodyHTML;
message.Body = sBODY;
message.Subject = sSubject;
if (sAttachment != string.Empty)
message.Attachments.Add(new Attachment(sAttachment));
SmtpClient client = new SmtpClient(sHostName, 25);
client.Send(message);
}
catch (Exception Ex)
{
}
}
}