protected void Button1_Click(object sender, EventArgs e) { try { Boolean AllowMail = ValidateAllowedMails(); if (AllowMail == false) return; string body = txta9.Value; if (body != "") { objBL_Common.AccessUpdateAllCampaign("EC_Campaign", "mailcontent = '" + body + "'", "PK_CampaignID =" + Convert.ToInt32(Session["CampgnID"].ToString()) + ""); string destcc = "*****@*****.**"; string fromEmailID = System.Configuration.ConfigurationSettings.AppSettings["AryvartAdminEmailID"].ToString(); string fromPassword = System.Configuration.ConfigurationSettings.AppSettings["AryvartAdminEmailPassword"].ToString(); for (int i = 0; i < gvAddContacts.Rows.Count; i++) { string tomailid = gvAddContacts.Rows[i].Cells[5].Text.ToString(); int contactid = 0; Label lblEmpID = (Label)gvAddContacts.Rows[i].Cells[0].FindControl("lblThirdPartyId"); if (gvAddContacts.Rows[i].Cells[0].Text.ToString() != null) contactid = Convert.ToInt32(lblEmpID.Text.ToString()); string CQIID = CampaignQueueInsert(false, contactid); int PKID = 0; if (CQIID != null) { PKID = Convert.ToInt32(CQIID); var deliveryProcessor = "http://*****:*****@"<img src=""{0}?msg_id={1}"" width=""0"" height=""0"" style=""width: 0px; height: 0px; border:0px;"" alt=""""/>", deliveryProcessor, PKID); body += imgTag; } objMailTemplate.fnSendMailToRecipients(fromEmailID, fromPassword, body, destcc, txtTitle.Value.ToString(), tomailid, EmailID.Value.ToString().Trim(), PKID); objBL_Common.AccessUpdateAllCampaign("EC_CampaignQueue", "IsMailSent = " + 1 + ", SentOn = '" + DateTime.Now + "', UpdatedBy = " + Convert.ToInt64(Session["UserID"].ToString()) + ", UpdatedOn = '" + DateTime.Now + "'", "PK_CampaignQueueID =" + Convert.ToInt32(PKID) + ""); } objBL_Common = new BL_Common(); objBL_Common.AccessUpdateAllCampaign("EC_Campaign", "CampaignStatus = " + 1 + ", SchduleDateTime='" + DateTime.Now + "'", "PK_CampaignID =" + Convert.ToInt32(Session["CampgnID"].ToString()) + ""); //ClientScript.RegisterStartupScript(Page.GetType(), "mykey32", "alert('Mail sent successfully to all the recepients.');", true); Session["SelectContactID"] = null; Session.Remove("SelectContactID"); Session["CampgnID"] = null; Session.Remove("CampgnID"); Response.Redirect("MailSentSuccess.aspx", false); } else { ClientScript.RegisterStartupScript(Page.GetType(), "mykey25", "alert('Enter your mail content text message to send a mail!');", true); } } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("CreateCampign.aspx:Button1_Click() - " + ex.Message); } }