ASP.NET with C# and SQL SERVER , some vb.net . asp.net examples, asp.net codes, asp.net programs, c# code, sql server queries, important codes.
Friday, 19 October 2012
send mail from asp.net c#
-----------------------------------------------------------
On csFile-----> At Registration Saving Time--------
-------------------------------------------------------------
Session["bk"] = "1";
if (txt_Email.Text != "")
{
logic.Send_Mail("info@progressivewebservices.com", txt_Email.Text, txt_UserName.Text.Trim(), id.ToString(), "Joining Info From PWS", "Welcome in PWS </br> You have successfully Registred . </br> Plz Login in PWS and Change your password ");
}
-----------------------------------------
On clsLogic----->
--------------------------------------------
#region Mail Section
public int Send_Mail(string mainfrom ,string mailto, string name, string pwd, string subject, string message)
{
try
{
string sbody = "";
sbody += "<html>";
sbody += "<body>";
sbody += "<table width='100%'>";
sbody += "<tr>";
sbody += "<td align='center' style='FONT-WEIGHT: bold;COLOR: #ffffff; FONT-SIZE: medium; FONT-STYLE: italic; BACKGROUND-COLOR: #A55129; FONT-VARIANT: small-caps'>" + "<b>" + "" + "</b>" + "</td>";
sbody += "</tr>";
sbody += "</table>";
sbody += "</body>";
sbody += "</html>";
sbody += "<html><head><title>Safe Life</title></head><body>" + "<p>From :<font color='red'> " + mainfrom + "</font></p>" + "<p>Title : " + subject + "</p>" + "<p></p>" + "</body></html>";
sbody += "\n";
sbody += "Name:" + name;
sbody += "<br>";
sbody += "UserID :" + pwd;
sbody += "<br>";
sbody += "<br>";
sbody += "Password :" + pwd;
sbody += "<br>";
sbody += "Message:";
sbody += message;
MailMessage msg = new MailMessage(mainfrom, mailto, subject, sbody);
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.yourDomain.com";
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "info@progressivewebservices.com";
NetworkCred.Password = "123456";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(msg);
return 1;
}
catch (Exception ex)
{
return 1;
}
}
//Function for Mail to Admin Email
public void Mail_Admin(string msg)
{
//Send_Mail("creativeProduct@yahoo.com", "CreativeProduct", "10000000", "Exception Message", msg);
}
#endregion
------------------------------------------------------------------
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment