| Author: manoj 02 Sep 2008 | Member Level: Silver | Rating: Points: 2 |
hai
if u are fetching a date from database means just u fetch a date in this format convert(varchar(12),Date(databsefieldname),103) as Date
|
| Author: Appukuttan 02 Sep 2008 | Member Level: Diamond | Rating: Points: 6 |
If u use format dd-MMM-yyyy defanitly u will get this format(02-sep-2008);
formail : 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()); } }
protected string fnGetAdminEmployees() { string Emailid = string.Empty; List<UserEntity> lstUser = Database.SelectFrom(UserEntity.Table) .Where(UserEntity.Table.Active == true && UserEntity.Table.Role.FullRights == true && UserEntity.Table.Role.Active == true) .LoadList<UserEntity>(); if (lstUser.Count > 0) { foreach (UserEntity objUser in lstUser) { Emailid += objUser.Employee.CorrespondAddress.Email + ","; } if (Emailid != "") { Emailid = Emailid.Substring(0, Emailid.Length - 1); } } return Emailid; }
protected string fnGetHigherAuthority() { string Ha_emailid = string.Empty; EmployeeEntity objEmp = Database.SelectFrom(EmployeeEntity.Table) .Where(EmployeeEntity.Table.Id == VetCareSession.LoginID) .LoadEntity<EmployeeEntity>(); if (objEmp != null) { Ha_emailid = objEmp.ReportingTo.CorrespondAddress.Email; } return Ha_emailid; }
|
| Author: Karthikeyan S 02 Sep 2008 | Member Level: Gold | Rating: Points: 3 |
Hi,
1. Whether you used the .ToString() function to format the datetime variable. If so it should work compulsarly else you have did some other mistake.
Syntax for this is: String lstrDate = ldateLoggedInDate.ToString("dd-MMM-yyyy");
2. Get data from database to a datatable.
a. Get data from database to a datatable: query for this 'SELECT Email_ID FROM EMAIL_TABLE' and use the dataadapter and fill the datatable "ldtEmailIDs".
b. use foreach loop and concatenate each email ids.
System.Net.Mail.MailMessage newEmail = new System.Net.Mail.MailMessage(); // or you can use smtp email also ur choice.
foreach(DataRow ldr in ldtEmailIDs.Rows) { //newEmail.To.Add("abcd@abcd.com"); newEmail.To.Add(ldr[0].ToString()); // in this way get emailids from //db and add it to "To" object of email object. }
... your code follows.
|
| Author: sweety 02 Sep 2008 | Member Level: Gold | Rating: Points: 3 |
protected void ButtonSubmit_Click(object sender, System.EventArgs e) { Server.ScriptTimeout = 1000; Response.Flush();
SmtpMail.SmtpServer = "localhost"; MailMessage mail = new MailMessage(); mail.To = this.TextBoxTo.Text; mail.Cc = this.TextBoxCc.Text; mail.Bcc = this.TextBoxBcc.Text; mail.From = this.TextBoxFrom.Text; mail.Subject = this.TextBoxSubject.Text; mail.Body = this.TextBoxBody.Text;
try { SmtpMail.Send(mail); Response.Write("The Mail has been sent to: "); Response.Write(mail.To); Response.Write(mail.Cc); Response.Write(mail.Bcc); } catch(System.Exception ex) { Response.Write(ex.Message); }
Response.Flush(); }
Points of Interest
|
| Author: Sabu C Alex 03 Sep 2008 | Member Level: Gold | Rating: Points: 2 |
hai
DateTime dt = DateTime.Now; String dte = dt.ToString("dd-MMM-yyyy");
Hope this will help you Sabu
|