Thursday, March 25, 2010

Smtp Mail send

Smtp Mail send



Using This Code Send Smtp Mail as Simple way Where No attachment Write This code In Send mail event Change Smatp Server as your mailserverip instead of "localhost"

Server.ScriptTimeout = 1000;
Response.Flush();

SmtpMail.SmtpServer = "localhost"; 
MailMessage mail = new MailMessage();
mail.To = this.TextBoxTo.Text;
mail.Cc = this.TextBoxCc.Text;
mail.Bcc = this.TextBoxBcc.Text;
mail.From = this.TextBoxFrom.Text;
mail.Subject = this.TextBoxSubject.Text;
mail.Body = this.TextBoxBody.Text;
   
try
{
SmtpMail.Send(mail);
Response.Write(" The Mail has been sent to: 
"); Response.Write("• To: " + mail.To + ""); Response.Write("• Cc: " + mail.Cc + ""); Response.Write("• Bcc: " + mail.Bcc + ""); } catch(System.Exception ex) { Response.Write("An erros has occured: " + ex.Message + "
"); } Response.Flush();