Ejemplo n.º 1
0
 protected void btn_New_onClick(object sender, EventArgs e)
 {
     if (ActionController.IsSessionExpired(Page))
     {
         ActionController.RedirctToLogin(Page);
     }
     else
     {
         txt_AMDDate.Text = DateTime.Now.Date.ToString();
         Hashtable validationHash     = new Hashtable();
         FSL.Cryptography.BlowFish bw = new FSL.Cryptography.BlowFish();
         bw.Initialize("flologic");
         txt_Password.Text   = bw.Encrypt(txt_Add_Password.Text);
         txtParameterID.Text = "0";
         string Result   = string.Empty;
         string isInsert = string.Empty;
         try
         {
             bool flag = ActionController.ValidateForm(Page, "insert", validationHash);
             if (flag)
             {
                 string str = txtCreatedBy.Text;
                 Result = (string)ActionController.ExecuteAction(this, "insert", ref isInsert);
                 if ((Result == null && isInsert.Length > 0) || isInsert == "false")
                 {
                     string[] errmsg = isInsert.Split(':');
                     Page.RegisterStartupScript("onclick", "<script language='javascript'>{alert('" + errmsg[1].ToString() + "');}</script>");
                 }
                 else
                 {
                     Page.RegisterStartupScript("onclick", "<script language='javascript'>{alert('Data Saved.');}</script>");
                     tbl_showMyAddPanel.Style["display"]    = "none";
                     tbl_showMyButtonPanel.Style["display"] = "block";
                     txt_Add_Address1.Text             = "";
                     txt_Add_Address2.Text             = "";
                     txt_Add_Email.Text                = "";
                     txt_Add_EmployeeName.Text         = "";
                     txt_Add_Password.Text             = "";
                     ddl_Add_Department.SelectedIndex  = 0;
                     ddl_Add_Designation.SelectedIndex = 0;
                     ddl_Add_IsActive.SelectedIndex    = 0;
                     ddl_Add_City.SelectedIndex        = 0;
                     txt_Add_UserName.Text             = "";
                 }
             }
             else
             {
                 DivDisplayError.Style["Display"] = "block";
             }
         }
         catch (Exception ex)
         {
             FSL.Logging.Logger.WriteEventLog(false, ex);
         }
     }
 }
Ejemplo n.º 2
0
    public void SendHtmlMail(string to, string cc, string subjects, string bodymsg, string imgpath)
    {
        // bool result = false;
        try
        {
            string frommail    = ConfigurationSettings.AppSettings["frommailid"].ToString();
            string mailpwd     = ConfigurationSettings.AppSettings["frommailidpwd"].ToString();
            string hostname    = ConfigurationSettings.AppSettings["mailhost"].ToString();
            string port        = ConfigurationSettings.AppSettings["smtpport"].ToString();
            bool   isSSLEnable = Convert.ToBoolean(ConfigurationSettings.AppSettings["isSSLEnable"].ToString());
            FSL.Cryptography.BlowFish BFISH = new FSL.Cryptography.BlowFish(GetPublicKey1());
            string      password            = BFISH.Decrypt(mailpwd);
            MailMessage msgMail             = new MailMessage();
            MailMessage myMessage           = new MailMessage();
            myMessage.From = new MailAddress(frommail);
            myMessage.To.Add(to);

            if (cc != "")
            {
                myMessage.CC.Add(cc);
            }
            myMessage.Subject = subjects;

            LinkedResource logo = new LinkedResource(imgpath, "images/gif");
            logo.ContentId = "companylogo";
            // done HTML formatting in the next line to display my logo
            AlternateView av1 = AlternateView.CreateAlternateViewFromString(bodymsg + "", null, MediaTypeNames.Text.Html);
            av1.LinkedResources.Add(logo);
            myMessage.AlternateViews.Add(av1);
            myMessage.IsBodyHtml = true;
            myMessage.Body       = bodymsg;
            //Attachment imgAtt = new Attachment(imgpath);
            //myMessage.Attachments.Add(imgAtt);
            SmtpClient mySmtpClient = new SmtpClient();
            System.Net.NetworkCredential myCredential = new System.Net.NetworkCredential(frommail, password);
            mySmtpClient.Host = hostname;
            mySmtpClient.Port = int.Parse(port);
            mySmtpClient.UseDefaultCredentials    = false;
            mySmtpClient.Credentials              = myCredential;
            mySmtpClient.ServicePoint.MaxIdleTime = 1;
            mySmtpClient.EnableSsl = isSSLEnable;
            object state = myMessage;
            mySmtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendHtmlCompleted);

            mySmtpClient.SendAsync(myMessage, state);
        }
        catch (Exception ex)
        {
            FSL.Logging.Logger.WriteEventLog(false, ex);
        }
    }