in the web.config
<appSettings>
<add key="SMTP" value="hostname.com"/>
<add key="FROMEMAIL" value="myemailadderss@yahoo.com"/>
<add key="FROMEPWD" value="ur email pwd">
<add key="PORT" value="25">
</appSettings>
and use following code to send the mail
protected bool Send(string To, string From, string Subj, string Msg)
{
try
{
string mFrom = From.ToString().Trim();
string mTo = To.ToString().Trim();
string mSubject = Subj.ToString().Trim();
string mMsg = Msg.ToString().Trim();
string mMailServer = ConfigurationManager.AppSettings.Get("SMTP");
int mPort = Convert.ToInt32(ConfigurationManager.AppSettings.Get("PORT"));
MailMessage message = new MailMessage(mFrom, mTo, mSubject, mMsg);
SmtpClient mySmtpClient = new SmtpClient(mMailServer, mPort);
message.Priority = MailPriority.High;
mySmtpClient.UseDefaultCredentials = true;
mySmtpClient.Send(message);
return true;
}
catch (Exception ex)
{
return false;
}
}