当ASP.net C#按钮单击发送电子邮件通知时显示Gif

时间:2018-09-11 07:56:45

标签: c# asp.net email

protected void btnPlaceOrder_Click(object sender, EventArgs e)
    {
        string CS = ConfigurationManager.ConnectionStrings["DBPCS"].ConnectionString;
        using (SqlConnection con = new SqlConnection(CS))
        {
            SqlCommand cmd = new SqlCommand("spGenerateInvoice", con);
            cmd.CommandType = CommandType.StoredProcedure;


            decimal GrossAmoutValue = ((decimal)ViewState["SubTotalAmount"] + (decimal)ViewState["TotalVatAmount"]);

            SqlParameter OrderId = new SqlParameter("@OrderId", ViewState["OrderId"]);
            SqlParameter Quantity = new SqlParameter("@Quantity", ViewState["TotalQuantity"]);
            SqlParameter Subtotal = new SqlParameter("@Subtotal", ViewState["SubTotalAmount"]);
            SqlParameter VatAmount = new SqlParameter("@VatAmount", ViewState["TotalVatAmount"]);
            SqlParameter GrossAmount = new SqlParameter("GrossAmount", GrossAmoutValue);

            cmd.Parameters.Add(OrderId);
            cmd.Parameters.Add(Quantity);
            cmd.Parameters.Add(Subtotal);
            cmd.Parameters.Add(VatAmount);
            cmd.Parameters.Add(GrossAmount);

            con.Open();
            lblMessage.ForeColor = System.Drawing.Color.Pink;
            lblMessage.Text = " OrderPlaced Successfully ";
            int InvoiceNo = (int)cmd.ExecuteScalar();            
            SendPasswordResetEmail(InvoiceNo.ToString());
            Server.Transfer("~/Purchase Management/OrderPlacedConfirmation.aspx");
            Response.Redirect("~/PrintInvoiceN.aspx?Invoice=" + InvoiceNo);

        }
    }

    private void SendPasswordResetEmail(string UniqueId)
    {

        MailMessage mailMessage = new MailMessage("noreply@cleanme.in", "asgar7electrical@gmail.com");
        StringBuilder sbEmailBody = new StringBuilder();
        sbEmailBody.Append("Dear sir, " + "<br/><br/>");
        sbEmailBody.Append("There is New Purchase Order waiting for Your Approval");
        sbEmailBody.Append("<br/><br/>");
        sbEmailBody.Append("http://Cleanme.in/Purchase Management/FinanceSignN.aspx?InvoiceNo=" + UniqueId);
        sbEmailBody.Append("<br/><br/>");
        sbEmailBody.Append("<b>Valueaddsfm Adminstrator</b>");

        mailMessage.IsBodyHtml = true;
        mailMessage.Body = sbEmailBody.ToString();
        mailMessage.Subject = "Alert : There is new PO for Approval with Order No. " + UniqueId;

        SmtpClient smtpClient = new SmtpClient("pss43.win.hostgator.com",25);
        smtpClient.Credentials = new System.Net.NetworkCredential()
        {
            UserName = "noreply@vcleanme.in",
            Password = "shjsd?20"
        };

        smtpClient.EnableSsl = false;
        smtpClient.Send(mailMessage);
    }

您好,如何在单击按钮时显示GIF图像单击“发送电子邮件”,通常,发送电子邮件需要15秒钟才能重定向到感谢页面。

我想向用户发送一封有关其订单确认的电子邮件。  SendPasswordResetEmail(InvoiceNo.ToString());之后,我要显示gif,直到发送10秒的邮件为止。然后重定向到谢谢页面

0 个答案:

没有答案