コード例 #1
0
 public void SendDeclineMail(string OrderNo)
 {
     try
     {
         UserOrderDetailsDal userOrderDetailsDal = new UserOrderDetailsDal();
         List <UserOrderDetailsResponseDto> userOrderDetailsResponseDto = userOrderDetailsDal.GetAllOrderDetails(OrderNo);
         List <UserOrderAndAddressDto>      userOrderAndAddressDto      = userOrderDetailsDal.GetUserAddressDetails(OrderNo);
         MailMessage mail = new MailMessage();
         mail.To.Add(userOrderDetailsResponseDto[0].EmailId);
         mail.From    = new MailAddress("*****@*****.**");
         mail.Subject = "Order Rejected";
         string body = System.IO.File.ReadAllText(HttpContext.Server.MapPath("../EmailTemplate/DeclineEmailTemplate.html"));
         mail.Body       = body;
         mail.IsBodyHtml = true;
         SmtpClient smtp = new SmtpClient();
         //smtp.Host = "smtp.gmail.com";
         smtp.Host = "relay-hosting.secureserver.net";
         smtp.Port = 25;
         //smtp.Timeout = 2000000;
         //smtp.Port = 465;
         smtp.UseDefaultCredentials = true;
         smtp.Credentials           = new NetworkCredential("*****@*****.**", "Cybria@0909"); // Enter seders User name and password
         //smtp.EnableSsl = true;
         smtp.Send(mail);
     }
     catch (Exception ex)
     {
         ErrorLogFile(ex);
         //Console.Write(ex.ToString());
     }
 }
コード例 #2
0
        public void SendApproveMail(string OrderNo)
        {
            try
            {
                UserOrderDetailsDal userOrderDetailsDal = new UserOrderDetailsDal();
                List <UserOrderDetailsResponseDto> userOrderDetailsResponseDto = userOrderDetailsDal.GetAllOrderDetails(OrderNo);
                List <UserOrderAndAddressDto>      userOrderAndAddressDto      = userOrderDetailsDal.GetUserAddressDetails(OrderNo);
                using (MailMessage mm = new MailMessage("*****@*****.**", userOrderDetailsResponseDto[0].EmailId))
                {
                    mm.Subject = "Order Confirmation";
                    string body = System.IO.File.ReadAllText(HttpContext.Server.MapPath("../EmailTemplate/ApproveEmailTemplate.html"));
                    body = body.Replace("#OrderNumber", OrderNo);
                    var itemListBody       = string.Empty;
                    var userAddressBody    = string.Empty;
                    var billingDetailsBody = string.Empty;
                    userAddressBody += "<tr><td>" + userOrderAndAddressDto[0].Address + "</td></tr>";
                    userAddressBody += "<tr><td>" + userOrderAndAddressDto[0].Locality + "," + userOrderAndAddressDto[0].City + "," + userOrderAndAddressDto[0].State + "," + userOrderAndAddressDto[0].Country + "</td></tr>";
                    userAddressBody += "<tr><td>" + userOrderAndAddressDto[0].Pincode + "</td></tr>";

                    billingDetailsBody += "<tr><td>Total Amount:</td><td>" + userOrderAndAddressDto[0].TotalAmount + "</td></tr>";
                    billingDetailsBody += "<tr><td>Shipping Charge:</td><td>0.00</td></tr>";
                    //billingDetailsBody += "<tr><td>Mode Of Payment:</td><td>" + userOrderAndAddressDto[0].PaymentType + "</td></tr>";

                    foreach (var item in userOrderDetailsResponseDto)
                    {
                        itemListBody += "<tr class='tr'><td class='td'><img src = '" + "https://chandnicreativeart.com/UploadImages/" + item.ItemImage + "' height='80' width='80' /></td><td class='td'>";
                        itemListBody += "<table class='table' style='font-family:'Open Sans', Arial, sans-serif; font-size:14px; line-height:17px; color:black;' valign='top'>";
                        itemListBody += "<tr><td><b>" + item.ItemName + "</b></td></tr><tr><td>Quantity</td><td>" + item.Quantity + "</td></tr><tr><td>Price</td>";
                        itemListBody += "<td><b>" + item.Price + "</b></td></tr></table></td></tr>";
                    }
                    body          = body.Replace("#userAddress", userAddressBody);
                    body          = body.Replace("#billingDetails", billingDetailsBody);
                    body          = body.Replace("#itemList", itemListBody);
                    mm.Body       = body;
                    mm.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient();
                    //smtp.Host = "smtp.gmail.com";
                    smtp.Host = "relay-hosting.secureserver.net";
                    //smtp.EnableSsl = true;
                    //smtp.Timeout = 2000000;
                    NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "Cybria@0909");
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials           = NetworkCred;
                    //smtp.Port = 587;
                    smtp.Port = 25;
                    smtp.Send(mm);
                }
            }
            catch (Exception ex)
            {
                ErrorLogFile(ex);
            }
        }