コード例 #1
0
    protected void zipValBut_Click(object sender, EventArgs e)
    {
        //string Name = GeneralFunc.ToProper(txtContcname.Text).Trim();
        //string Phone = txtphone.Text;
        //string Email = txtemail.Text;
        clsMailFormats format = new clsMailFormats();
        MailMessage msg = new MailMessage();
        if (Session["CustEmail"] != null)
        {
            if (Session["CustEmail"].ToString() != "")
            {
                msg.From = new MailAddress(txtcemail.Text);
                msg.To.Add(Session["CustEmail"].ToString());
                msg.CC.Add("*****@*****.**");
                msg.Bcc.Add(CommonVariable.ArchieveMail);
                msg.Subject = "Regarding Buyer requestbu";
                msg.IsBodyHtml = true;
                string text = string.Empty;

                string Comments = string.Empty;
                if (txtComments.Text == "Enter your message here")
                {
                    Comments = "";
                }
                else
                {
                    Comments = txtComments.Text;
                }

                text = format.SendContactSellar(lblSellerName.Text, zipCode1.Text, txtPhone.Text, txtcemail.Text, GeneralFunc.ToProper(txtfirstName.Text), txtlastName.Text,
                    Comments, ref text, lblYear.Text, lblMake.Text, lblModel.Text, lblPrice.Text);

                msg.Body = text.ToString();

                SmtpClient smtp = new SmtpClient();

                //smtp.Host = "smtp.gmail.com";
                //smtp.Port = 587;
                //smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "hugomirad");
                //smtp.EnableSsl = true;
                //smtp.Send(msg);

                smtp.Host = "127.0.0.1";
                smtp.Port = 25;
                smtp.Send(msg);

                MpeEmail.Hide();

                lblAlertMsg.Text = "Email request sent to seller.";

                mpealert.Show();

                //Page.ClientScript.RegisterStartupScript(typeof(Page), "KyRST", "<script type='text/javascript' language='javascript'>alert('');</script>");

                Page.ClientScript.RegisterStartupScript(typeof(Page), "KyRST", "<script type='text/javascript' language='javascript'>hide();</script>");

                Page.ClientScript.RegisterStartupScript(typeof(Page), "KyRST", "<script type='text/javascript' language='javascript'>pageLoad();</script>");

                BuyerTranBL objBuyerTranBL = new BuyerTranBL();

                bool bSuccess = true;
                String strHostName = HttpContext.Current.Request.UserHostAddress.ToString();
                string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

                bSuccess = objBuyerTranBL.SaveBuyerRequest(txtcemail.Text, zipCode1.Text, txtPhone.Text, GeneralFunc.ToProper(txtfirstName.Text),
                    txtlastName.Text, Comments, strIp, lblphone.Text, lblPrice.Text, hdnCarid.Value, "0");

                zipCode1.Text = "Zip or City";

                txtPhone.Text = "my phone number";

                txtcemail.Text = "my email address";

                txtfirstName.Text = "First Name";

                txtlastName.Text = "Last Name";

                txtComments.Text = "Enter your message here";

            }
            else
            {
                Page.ClientScript.RegisterStartupScript(typeof(Page), "KyRST", "<script type='text/javascript' language='javascript'>alert('Seller Email id doesnot exists');</script>");
            }
        }
    }