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);
        }
    }