C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




hi All How To Send Mail Through ASP. Any Free SMTP Server


Posted Date: 15 Oct 2008      Total Responses: 1

Posted By: sandip chavan       Member Level: Silver     Points: 1


hi All.


I Want To Send Mail through Asp.How to get SMTP Server free Name For Tril
Code




Responses

Author: Athira Appukuttan    15 Oct 2008Member Level: DiamondRating:     Points: 6
u can send mail like this..
using System.Net.Mail;

private void fnSendmail()
{
string Empname = string.Empty;
string Gender = string.Empty;
string sGender = string.Empty;
string EmailId = string.Empty;
try
{
EmployeeEntity objEmp = Database.SelectFrom(EmployeeEntity.Table)
.Where(EmployeeEntity.Table.Id == VetCareSession.LoginID)
.LoadEntity<EmployeeEntity>();
if (objEmp != null)
{
Empname = objEmp.Name;
Gender = objEmp.Gender;
EmailId = objEmp.CorrespondAddress.Email;
}
if (Gender == "Female")
{
sGender = "her";
}
else
{
sGender = "his";
}
//Getting Admin email id's and Higher authority Email id's
string strMailId = fnGetAdminEmployees();
string strccMailid = fnGetHigherAuthority();

MailMessage m_newmail = new MailMessage();
SmtpClient s_client = new SmtpClient();
if (strMailId != "" && strccMailid != "" && EmailId != "")
{
m_newmail.To.Add(strMailId);
m_newmail.CC.Add(strccMailid);

MailAddress fromAdr = new MailAddress(EmailId);
m_newmail.From = fromAdr;
m_newmail.Subject = "About employee's address status ";
m_newmail.Body = Empname + " has been changed " + sGender + " Correspondance / Permanent Address";
m_newmail.IsBodyHtml = true;
s_client.Host = "localhost";
s_client.UseDefaultCredentials = true;
s_client.Send(m_newmail);

ClientScript.RegisterClientScriptBlock(this.GetType(), "Hi!", String.Format("alert('An email has successfully been sent to {0}');", m_newmail.To), true);
m_newmail.Dispose();

}
}
catch (Exception ex)
{
// Response.Write(ex.ToString());
}
}



Post Reply
You must Sign In to post a response.
Next : Error while Authenticating a form
Previous : compare value with database in asp.net
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use