| Author: Athira Appukuttan 15 Oct 2008 | Member Level: Diamond | Rating: 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()); } }
|