How to send mail to another email id using C#.Net
C# Code:
MailMessage Msg = new MailMessage();
string
FromMail = "noreply@softtechsolving.com";
string Password
= "XXXXXXX"; //”XXXXXX” is
email id password
Msg.From = new
MailAddress(FromMail);
// Recipient
e-mail address..
string
ToMail = txtEmail.Text;
Msg.To.Add(ToMail);
string
MsgBody = "welcome to softtechsolving…";
AlternateView
htmlMsgView = AlternateView.CreateAlternateViewFromString(MsgBody,
null, MediaTypeNames.Text.Html);
Msg.AlternateViews.Add(htmlMsgView);
Msg.Subject = "softtechsolving";
Msg.Body = MsgBody;
//send the
message
SmtpClient
smtp = new SmtpClient("mail.softtechsolving.com");
//to
authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = new NetworkCredential(FromMail,
Password);
smtp.Send(Msg);
Namespace:
using System;
using
System.Collections;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
System.Data.SqlClient;
using System.IO;
using
System.Net;
using
System.Net.Mail;
using
System.Net.Mime;