protected void Button_Click(object sender, EventArgs e)
        {
            IList<UserBidInformation> userBidInformationList = _databaseComponents.GetInformation(Session["name"].ToString(),Session["phone"].ToString());
            Email sendEmail = new Email();

            sendEmail.RecepientEmail = (email.Text).Trim();
            sendEmail.Subject = "Thanks for bidding";
            sendEmail.EmailBody = "<html>"
                                + "<head>"
                                + " <title></title>"
                                + "</head>"
                                + "<h1 style='color: red' align='center'>Festival of Trees</h1>"
                                + "<h3 style='color: green' align='center'>The best way to start your  holidays</h3>"
                                + "<center> <img src = 'http://grinnell.lib.ia.us/wp-content/uploads/2014/10/Festival-of-Trees-Logo.jpg' alt='Logo' style='width:200px; height:200px;' align='middle'/></center>"
                                + "<h2 align = 'center' style = 'color:red' > Invoices </h2>"
                                + "<h4 style = 'color:green' align = 'center'><i> We appreciate your support of the Festival of Trees on behalf of the Baby Fold. During the event you purchased the following items: </i></h4>"
                                + "<table style='width:100%' align='center' cellpadding='2' cellspacing='2' border='2' bgcolor='#EAEAEA'>"
                                + "<tr>"
                                + "<th>BidID</th>"
                                + " <th>Email</th>"
                                + "<th>Name</th>"
                                + "<th>Bid Amount</th>"
                                + "<th>Phone Number</th>"
                                + "<th>Payment status</th>"
                                + "</tr>";

            foreach (UserBidInformation details in userBidInformationList)
            {
                sendEmail.EmailBody += " <tr><td>" + details.BidId + "</td>"
                                          + "<td>" + details.Email + "</td>"
                                          + "<td>" + details.Name + "</td>"
                                          + "<td>" + details.BidAmount + "</td>"
                                          + "<td>" + details.PhoneNumber + "</td>"
                                          + "<td>" + details.PaymentStatus + "</td>"
                                          + "</tr>";
            }

            sendEmail.EmailBody += "</table>"
                                + "<pre style = 'color:red' align='left'>Thank You For Your Generosity <br/>"
                                + "Sincerely,<br/>"
                                + "Co-Chair</pre><br/>"
                                + "<hr>"
                                + "<h4 style = 'color:green' ><i> A portion of your purchase is tax deductable.For each item, the amount of your purchase preice which is in excess of the fair market value for that item may be an allowable charitable deduction.According to federal guidelines youa re able to deduct $ 0.00 as a charitable contribution.</i> </h4>"
                                + "</body></html>";

            var result = sendEmail.SendEmail(sendEmail);
            Response.Write(result ? "Email Sent successfully" : "Failed to send email!");
            //After clicking on the Send Email button we are redirecting the user to a page that will show all the bids that has been placed by him/her.
            //We are showing all the bids here, however, if we want to show only won bids then we need to put condition in the query written for the gridview on
            //ShowBidToUser.aspx page.
            //Response.Redirect("ShowBidToUser.aspx", false);
        }
Exemplo n.º 2
0
 public Boolean SendEmail(Email email)
 {
     var messageFrom = new MailAddress("*****@*****.**", "Festival of Trees");
     var emailMessage = new MailMessage {From = messageFrom};
     var messageTo = new MailAddress(email.RecepientEmail);
     emailMessage.To.Add(messageTo.Address);
     var messageSubject = email.Subject;
     var messageBody = email.EmailBody;
     emailMessage.Subject = messageSubject;
     emailMessage.Body = messageBody;
     emailMessage.IsBodyHtml = true;
     var mailClient = new SmtpClient("smtp.ilstu.edu");
     try
     {
         mailClient.UseDefaultCredentials = true;
         mailClient.Send(emailMessage);
     }
     catch (Exception e)
     {
         Console.Write(e);
         return false;
     }
     return true;
 }
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (Session["newemail"]==null)
            {
                Label4.Text = "Please enter the bidder's email!";
                TextBox3.Visible = false;
                TextBox4.Visible = true;
                Button3.Visible = true;

            }

               else
            {

                //string str = "SELECT email FROM TempBidder Where winningStatus='winner' and name= '" + TextBox1.Text+ "' and phoneNum= '" + TextBox2.Text + "';";
                //SqlCommand checklogin = new SqlCommand(str, connection);
                //SqlDataReader record = checklogin.ExecuteReader();

                //if (record.Read())
                //{
                //    Session["newemail"] = record[0].ToString();
                //}

                string name = Session["firstnameForEmail"].ToString();
                string phone = Session["phoneForEmail"].ToString();
                IList<UserBidInformation> userBidInformationList = _databaseComponents.GetInformation(name,phone);
                Email sendEmail = new Email();

                sendEmail.RecepientEmail = (Session["newemail"].ToString().Trim());
                sendEmail.Subject = "Thanks for bidding";
                sendEmail.EmailBody = "<html>"
                                    + "<head>"
                                    + " <title></title>"
                                    + "</head>"
                                    + "<h1 style='color: red' align='center'>Festival of Trees</h1>"
                                    + "<h3 style='color: green' align='center'>The best way to start your  holidays</h3>"
                                    + "<center> <img src = 'http://grinnell.lib.ia.us/wp-content/uploads/2014/10/Festival-of-Trees-Logo.jpg' alt='Logo' style='width:200px; height:200px;' align='middle'/></center>"
                                    + "<h2 align = 'center' style = 'color:red' > Invoices </h2>"
                                    + "<h4 style = 'color:green' align = 'center'><i> We appreciate your support of the Festival of Trees on behalf of the Baby Fold. During the event you purchased the following items: </i></h4>"
                                    + "<table style='width:100%' align='center' cellpadding='2' cellspacing='2' border='2' bgcolor='#EAEAEA'>"
                                    + "<tr>"
                                    + "<th>BidID</th>"
                                    + " <th>Email</th>"
                                    + "<th>Name</th>"
                                    + "<th>Bid Amount</th>"
                                    + "<th>Phone Number</th>"
                                    + "<th>Payment status</th>"
                                    + "</tr>";
                double totalBidAmount = 0;
                foreach (UserBidInformation details in userBidInformationList)
                {
                    sendEmail.EmailBody += " <tr><td>" + details.BidId + "</td>"
                                              + "<td>" + details.Email + "</td>"
                                              + "<td>" + details.Name + "</td>"
                                              + "<td>" + details.BidAmount + "</td>"
                                              + "<td>" + details.PhoneNumber + "</td>"
                                              + "<td>" + details.PaymentStatus + "</td>"
                                              + "</tr>";
                    totalBidAmount += Convert.ToDouble(details.BidAmount);
                }

                sendEmail.EmailBody += "</table><h3>Your Total Expenditure: "+ totalBidAmount + "</h3>"
                                    + "<pre style = 'color:red' align='left'>Thank You For Your Generosity <br/>"
                                    + "Sincerely,<br/>"
                                    + "Co-Chair</pre><br/>"
                                    + "<hr>"
                                    + "<h4 style = 'color:green' ><i> A portion of your purchase is tax deductable.For each item, the amount of your purchase preice which is in excess of the fair market value for that item may be an allowable charitable deduction.According to federal guidelines youa re able to deduct $ 0.00 as a charitable contribution.</i> </h4>"
                                    + "</body></html>";

                var result = sendEmail.SendEmail(sendEmail);
                //Response.Write(result ? "Email Sent successfully" : "Failed to send email!");
                Label4.Visible = false;
                Label5.Visible = true;
                Label5.Text = "Email Sent successfully";

                //After clicking on the Send Email button we are redirecting the user to a page that will show all the bids that has been placed by him/her.
                //We are showing all the bids here, however, if we want to show only won bids then we need to put condition in the query written for the gridview on
                //ShowBidToUser.aspx page.
                //Response.Redirect("ShowBidToUser.aspx", false);

                //foreach (string car in st)
                //{
                //    Response.Write(car + "<br/>");
                //}

            }
        }