public void SendMail(doEmailTemplate template, List <string> mailAddress) { try { SendMailObject obj = new SendMailObject(); if (template != null && mailAddress != null) { obj.EmailList = new List <doEmailProcess>(); foreach (string addr in mailAddress) { doEmailProcess mail = new doEmailProcess() { MailTo = addr, Subject = template.TemplateSubject, Message = template.TemplateContent }; obj.EmailList.Add(mail); } } System.Threading.Thread t = new System.Threading.Thread(SendMail); t.Start(obj); } catch (Exception) { throw; } }
protected void btnSendMail_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } try { IncentiveBusiness b = new IncentiveBusiness(); EmailDetails details = new EmailDetails(); SendMailObject obj = new SendMailObject(); details.FromEmail = ConfigurationManager.AppSettings["FromAddress"].ToString(); string finance_emailid = Session["emailId"].ToString(); string employeeid = Session["MemberId"].ToString(); string referenceid = Session["referenceid"].ToString(); string toemail = txtTo.Text; string ccmail = txtCC.Text; details.ToEmail = toemail.ToString(); details.CCEmail = ccmail.ToString(); details.Type = referenceid; details.Id = ""; details.Module = Session["transctiontype"].ToString(); string FooterText = ConfigurationManager.AppSettings["FooterText"].ToString(); details.EmailSubject = txtSubject.Text; details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"> <br>" + "<b> '" + txtMsgContent.Text + "' <br> " + "<br>" + "<br>" + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; bool resultv = obj.InsertIntoEmailQueue(details); if (resultv == true) { bool flag = b.UpdateUtilizationMailFlag(employeeid, referenceid, Session["transctiontype"].ToString()); Gridview.DataBind(); Gridview.Visible = true; PanelSendMail.Visible = false; txtTo.Text = ""; txtCC.Text = ""; txtSubject.Text = ""; txtMsgContent.Text = ""; string CloseWindow1 = "alert('Mail Sent successfully')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); } else { PanelSendMail.Visible = true; string CloseWindow1 = "alert('Problem while sending mail')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); } } catch (Exception ex) { log.Error(ex.StackTrace); log.Error(ex.Message); } }
private void SendMail() { EmailDetails details = new EmailDetails(); try { bool resultv = false; IncentiveBusiness b = new IncentiveBusiness(); SendMailObject obj = new SendMailObject(); string memberid = txtMemberId.Text.Trim(); string emailid = b.SelectAuthorEmailId(memberid); string point = txtPointsAwarded.Text; string year = DdlYear.SelectedValue; details.FromEmail = ConfigurationManager.AppSettings["FromAddress"].ToString(); details.ToEmail = emailid; details.Module = "APA"; details.EmailSubject = "Additional Point Award"; details.Type = ""; details.Id = ""; string FooterText = ConfigurationManager.AppSettings["FooterText"].ToString(); details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + "<p>An additional incentive point for the year '" + year + "' is awarded '" + point + "' for more than 6 publication.</p>" + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; resultv = obj.InsertIntoEmailQueue(details); if (resultv == true) { string CloseWindow1 = "alert('Mail Sent successfully')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); btnSave.Enabled = false; } else { string CloseWindow1 = "alert('Problem while sending mail')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); btnSave.Enabled = false; } } catch (Exception ex) { string CloseWindow1 = "alert('Problem while sending mail')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); log.Error(ex.Message); log.Error(ex.StackTrace); btnSave.Enabled = false; } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } try { obj.MemberId = txtboxMemberId.Text.Trim(); obj.CurrentBalance = Convert.ToDouble(txtcurbal.Text.Trim()); obj.TotalPoint = Convert.ToDouble(txtadjustment.Text.Trim()); obj.Remarks = txtRemarks.Text.Trim(); obj.CurrentBalance = obj.CurrentBalance + Convert.ToDouble(obj.TotalPoint); obj.TransactionType = "ADJ"; if (obj.TotalPoint > 0) { obj.NumberType = "Added"; } else { obj.NumberType = "Removed"; } bool result1 = B.UpdateCurBal(obj); //Business layer if (result1 == true) { string CloseWindow1 = "alert('Incentive Point Saved successfully')"; //ScriptManager.RegisterStartupScript(EditUpdatePanel, EditUpdatePanel.GetType(), "alert", CloseWindow1, true); ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); btnUpdate.Enabled = false; EmailDetails details = new EmailDetails(); details = SendMail(txtboxMemberId.Text, txtcurbal.Text, txtadjustment.Text, txtRemarks.Text, obj.CurrentBalance, obj.NumberType); SendMailObject obj1 = new SendMailObject(); bool resultv = obj1.InsertIntoEmailQueue(details); } else { string CloseWindow1 = "alert('Incentive Point Saved successfully')"; ScriptManager.RegisterStartupScript(EditUpdatePanel, EditUpdatePanel.GetType(), "alert", CloseWindow1, true); btnUpdate.Enabled = false; } } catch (Exception ex) { log.Error(ex.StackTrace); log.Error(ex.Message); ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>"); } }
public static void SendMail(object o) { try { SendMailObject obj = o as SendMailObject; if (obj == null) { return; } if (obj.EmailList != null) { ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; foreach (doEmailProcess mail in obj.EmailList) { chandler.SendMail(mail); } } } catch { } }
protected void BtnSend_Click(object sender, EventArgs e) { log.Info("ManualMailSender : Inside BtnSend_Click function"); string toaddress = ""; string cc = ""; string bcc = ""; string subject = ""; string id = ""; SendMailObject obj = new SendMailObject(); DataSet ds = new DataSet(); ds = obj.SelectEMailQueueDetails(); try { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { try { MailMessage Msg = new MailMessage(); System.Net.Mail.SmtpClient spcl = new System.Net.Mail.SmtpClient(); string password = ConfigurationManager.AppSettings["MailPassword"].ToString(); string from = ConfigurationManager.AppSettings["FromAddress"].ToString(); string footertext = ConfigurationManager.AppSettings["FooterText"].ToString(); subject = ds.Tables[0].Rows[i]["Subject"].ToString(); string to = ds.Tables[0].Rows[i]["ToEmail"].ToString(); cc = ds.Tables[0].Rows[i]["CC"].ToString(); bcc = ds.Tables[0].Rows[i]["BCC"].ToString(); string body = ds.Tables[0].Rows[i]["MsgBody"].ToString(); id = ds.Tables[0].Rows[i]["Id"].ToString(); Session["Module"] = ds.Tables[0].Rows[i]["Module"].ToString(); Msg.Subject = subject; if (cc != "") { string[] ccemaillist = cc.Split(','); for (int j = 0; j <= ccemaillist.GetUpperBound(0); j++) { Msg.CC.Add(ccemaillist[j]); } } if (bcc != "") { string[] bccemaillist = bcc.Split(','); for (int j = 0; j <= bccemaillist.GetUpperBound(0); j++) { Msg.Bcc.Add(bccemaillist[j]); } } Msg.Priority = MailPriority.Normal; Msg.IsBodyHtml = true; Msg.From = new MailAddress(from); Msg.Body = body; toaddress = ds.Tables[0].Rows[i]["ToEmail"].ToString(); if (toaddress != null) { string[] toaddress_value = toaddress.Split(','); for (int j = 0; j <= toaddress_value.GetUpperBound(0); j++) { Msg.To.Add(toaddress_value[j]); } } spcl.Host = ConfigurationManager.AppSettings["MailHost"].ToString(); spcl.Port = Convert.ToInt16(ConfigurationManager.AppSettings["SMTPPort"]); spcl.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSSL"]); spcl.Credentials = new System.Net.NetworkCredential(from, password); spcl.Send(Msg); bool result = obj.UpdateEmailSendFlag(id, Session["Module"], subject); if (result == true) { log.Info("ManualMailSender:Email is sent to sucessfully for the user (To adress) :" + toaddress + " subject: " + subject + " Module: " + Session["Module"] + " Id: " + id); if (cc != "") { log.Info("ManualMailSender:Email is sent to sucessfully for the user (CC) : '" + cc + "' "); } if (bcc != "") { log.Info(" ManualMailSender:Email is sent to sucessfully for the user (BCC) : '" + bcc + "' "); } ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Email is sent sucessfully')</script>"); } } catch (Exception ex) { // ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Problem in sending email')</script>"); log.Error(ex.StackTrace); log.Error(ex.Message); log.Error("ManualMailSender:Email Send Failed : '" + ex + "' "); log.Error("ManualMailSender:Email Failed for the user :"******" subject: " + subject + " Module: " + Session["Module"] + " Id: " + id); log.Error("ManualMailSender:Email Failed for the user :"******" subject: " + subject + " Module: " + Session["Module"] + " Id: " + id); log.Error("ManualMailSender:Email Failed for the user :"******" subject: " + subject + " Module: " + Session["Module"] + " Id: " + id); if (cc != "") { log.Info("ManualMailSender:Email Failed for the user (CC) : '" + cc + "' "); } if (bcc != "") { log.Info("ManualMailSender:Email Failed for the user (BCC) : '" + bcc + "' "); } } } } catch (Exception e1) { log.Error(e1.StackTrace); log.Error(e1.Message); log.Error("ManualMailSender:Email Send Failed : '" + e1 + "' "); ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Problem in sending email')</script>"); } }
private void SendMail() { EmailDetails details = new EmailDetails(); IncentiveBusiness b = new IncentiveBusiness(); SendMailObject obj = new SendMailObject(); Business e = new Business(); try { bool resultv = false; int rowIndex = 0; string emailid = null; details.Module = "IPE"; string AuthorName = null; string Isstudent = null; details.EmailSubject = "Incentive Point Adjustment"; string empcode = txtboxMemberId.Text; string type = e.selectMemberType(empcode, txtReferenceId.Text); if (type == "M") { //Isstudent = "N"; emailid = b.SelectAuthorEmailId(empcode); AuthorName = b.SelectAuthorName(empcode); Session["AuthorName"] = AuthorName; if (emailid == "") { int result; //string AuthorName; AuthorName = b.SelectAuthorName(empcode); result = e.insertEmailtrackerIncentive(AuthorName, details, txtReferenceId.Text); } } else { //Isstudent = "S"; emailid = b.SelectStudentEmailId(empcode, txtReferenceId.Text); AuthorName = b.SelectStudentAuthorName(empcode, txtReferenceId.Text); Session["AuthorName"] = AuthorName; if (emailid == "") { int result; AuthorName = b.SelectStudentAuthorName(empcode, txtReferenceId.Text); result = e.insertEmailtrackerIncentive(AuthorName, details, txtReferenceId.Text); //Session["AuthorName"] = AuthorName; } } details.FromEmail = ConfigurationManager.AppSettings["FromAddress"].ToString(); if (emailid != "") { details.ToEmail = emailid; } string hremailid = b.SelectHRMailID(empcode, type, txtReferenceId.Text); string InstWiseHRMailid = b.SelectInstwiseHRMailid(empcode, type, txtReferenceId.Text); if (details.ToEmail != null && details.ToEmail != "") { if (InstWiseHRMailid != null) { if (InstWiseHRMailid != "") { if (details.ToEmail != null) { details.ToEmail = details.ToEmail + "," + InstWiseHRMailid; } else { details.ToEmail = InstWiseHRMailid; } } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } else { if (InstWiseHRMailid != null) { if (InstWiseHRMailid != "") { if (details.ToEmail != null) { details.ToEmail = InstWiseHRMailid; } else { details.ToEmail = InstWiseHRMailid; } } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } ArrayList list = new ArrayList(); list = b.SelectHODMailid(empcode, type, txtReferenceId.Text); for (int j = 0; j < list.Count; j++) { if (j == 0) { if (list[j].ToString() != "") { details.HODmailid = list[j].ToString(); } } else { if (list[j].ToString() != "") { details.HODmailid = details.HODmailid + ',' + list[j].ToString(); } } } if (details.ToEmail != null && details.ToEmail != "") { if (hremailid != null) { if (hremailid != "") { details.ToEmail = details.ToEmail + "," + hremailid; } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } else { if (hremailid != null) { if (hremailid != "") { details.ToEmail = hremailid; } else { // details.ToEmail = details.ToEmail; } } else { // details.ToEmail = details.ToEmail; } } if (details.ToEmail != null && details.ToEmail != "") { if (details.HODmailid != null) { if (details.HODmailid != "") { details.ToEmail = details.ToEmail + "," + details.HODmailid; //details.ToEmail = details.ToEmail + "," + hremailid + "," + details.HODmailid; } else { //details.ToEmail = details.ToEmail; } } else { //details.ToEmail = details.ToEmail; } } else { if (details.HODmailid != null) { if (details.HODmailid != "") { details.ToEmail = details.HODmailid; //details.ToEmail = details.ToEmail + "," + hremailid + "," + details.HODmailid; } else { //details.ToEmail = details.ToEmail; } } else { //details.ToEmail = details.ToEmail; } } // details.CCEmail = hremailid; // details.CCEmail = Session["emailId"].ToString(); details.Module = "IPE"; details.EmailSubject = "Incentive Point Adjustment"; //details.Type = DropDownListPublicationEntry.SelectedValue; details.Id = txtReferenceId.Text; string FooterText = ConfigurationManager.AppSettings["FooterText"].ToString(); string isStudent = Session["IsStudent"].ToString(); if (isStudent == "Y") { if (type == "S") { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + "<p>For Certificate of Appreciation and encashment of research incentive points, request you to contact student research section of your institution/department along with the Bank detail form available in RMS Portal.</p>" + "<b>Incentive points with the rating : " + txtTotalPoint.Text + "" + Session["Numbertype"].ToString() + "<br>" + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } else { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + //"<b> Incentive points with the rating '" + total.Text + "' added. <br> " + "<b>Incentive points with the rating : " + txtTotalPoint.Text + " " + Session["Numbertype"].ToString() + "<br>" + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } } else { if (type == "S") { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + "<p>For encashment of research incentive points, request you to contact student research section of your institution/department along with the Bank detail form available in RMS Portal.</p>" + "<b>Incentive points with the rating : " + txtTotalPoint.Text + " " + Session["Numbertype"].ToString() + "<br>" + //"<b> Incentive points with the rating '" + total.Text + "' added. <br> " + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } else { details.MsgBody = "<span style=\"font-size: 10pt; color: #3300cc; font-family: Verdana\"><h4>Dear Sir/Madam,</h4> <br>" + //"<b> Incentive points with the rating '" + total.Text + "' added. <br> " + "<b>Incentive points with the rating : " + txtTotalPoint.Text + " " + Session["Numbertype"].ToString() + "<br>" + "<br>" + "Author Name : " + Session["AuthorName"].ToString() + "<br>" + "Publication Id : " + txtReferenceId.Text + "<br>" + "Article Name :" + Session["Title"].ToString() + "<br>" + "<br>" + FooterText + " </b><br><b> </b></span>"; } } if (details.ToEmail != "" && details.ToEmail != null) { resultv = obj.InsertIntoEmailQueue(details); } IncentiveData obj3 = new IncentiveData(); IncentiveBusiness C = new IncentiveBusiness(); if (emailid == "") { string AuthorName1 = Session["AuthorName"].ToString(); obj3 = C.CheckUniqueIdIncentive(txtReferenceId.Text, "JA", details); int data = C.updateEmailtrackerIncentive(txtReferenceId.Text, "JA", details, obj3, AuthorName1); } if (resultv == true) { string CloseWindow1 = "alert('Mail Sent successfully')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); } else { string CloseWindow1 = "alert('Problem while sending mail')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); } } catch (Exception ex) { string CloseWindow1 = "alert('Problem while sending mail')"; ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", CloseWindow1, true); log.Error(ex.Message); log.Error(ex.StackTrace); } }
protected void BtnSendMail_Click(object sender, EventArgs e) { try { IncentiveBusiness b = new IncentiveBusiness(); EmailDetails details = new EmailDetails(); SendMailObject obj = new SendMailObject(); details.FromEmail = ConfigurationManager.AppSettings["FromAddress"].ToString(); string finance_emailid = Session["emailId"].ToString(); int Index = ((GridViewRow)((sender as Control)).NamingContainer).RowIndex; string employeeid = Gridview.Rows[Index].Cells[0].Text; string referenceid = Gridview.Rows[Index].Cells[1].Text; string transctiontype = Gridview.Rows[Index].Cells[5].Text; Session["transctiontype"] = transctiontype; Session["MemberId"] = employeeid; Session["referenceid"] = referenceid; string membertype = Gridview.Rows[Index].Cells[6].Text; string emailid = null; if (membertype == "M") { emailid = b.SelectAuthorEmailId(employeeid); } else { //emailid = b.SelectStudentAuthorEmailId(employeeid); string id = ""; emailid = b.SelectStudentEmailId(employeeid, id); } string hr_emaild = b.SelectHREmailId(employeeid, referenceid, transctiontype); PanelSendMail.Visible = true; if (emailid != "") { txtTo.Text = hr_emaild + ',' + emailid; } else { txtTo.Text = hr_emaild; } txtCC.Text = finance_emailid; foreach (GridViewRow row in Gridview.Rows) { if (row.RowIndex == Index) { row.BackColor = ColorTranslator.FromHtml("#A1DCF2"); } else { row.BackColor = ColorTranslator.FromHtml("#FFFFFF"); } } } catch (Exception ex) { log.Error(ex.StackTrace); log.Error(ex.Message); //return obj1; } }