Exemplo n.º 1
0
        public IHttpActionResult SendEmail(SendEmailDTO value)
        {
            if (string.IsNullOrEmpty(value.EmailAddress))
            {
                return(BadRequest("email address is required"));
            }

            if (string.IsNullOrEmpty(value.Body))
            {
                return(BadRequest("email body is required"));
            }

            var email = new Email
            {
                To      = value.EmailAddress,
                Subject = string.Format("Message from OnRecord - {0}", CurrentUser.UserName),
                Content = WebHelpers.GenerateEmailTemplate(value.Body, "Message from OnRecord")
            };

            UnitOfWork.EmailsRepository.InsertOrUpdate(email);

            try
            {
                UnitOfWork.Save();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> SendEmail(SendEmailDTO model)
        {
            var emails = new List <string>();

            foreach (var item in model.emails)
            {
                emails.Add(item);
            }

            var response = await _emailService.SendEmailAsync("*****@*****.**", emails, model.Subject, model.Message);

            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                return(Ok("Email sent " + response.StatusCode));
            }
            else
            {
                return(BadRequest("Email sending failed " + response.StatusCode));
            }
        }
Exemplo n.º 3
0
    protected void btnConfirmOrder_Click(object sender, EventArgs e)
    {
        try
        {
            ltrMessage.Visible = false;

            if (Session[enumSessions.OrderId.ToString()] == null) /* If someone clicks on back button - when the confirmation message is shown.*/
            {
                Response.Redirect("Login.aspx");
            }
            else if (dlProducts.Items.Count == 0)
            {
                ltrMessage.Visible = true;
                ltrMessage.Text    = "No item is added to confirm the order. Please add an item first to confirm the order.";
            }
            else
            {
                LinqToSqlDataContext db = new LinqToSqlDataContext();
                var orderStatus         = (from o in db.Orders
                                           where o.OrderId == Convert.ToInt32(Session[enumSessions.OrderId.ToString()])
                                           select o.OrderStatusId).SingleOrDefault();
                if (orderStatus != 1)
                {
                    Response.Redirect("Categories.aspx");
                }
                this.MaintainScrollPositionOnPostBack = true;

                if (divNewAddress.Visible)
                {
                    Page.Validate("grpDeliveryAddress");
                }

                if (divInstallationAddress.Visible)
                {
                    Page.Validate("grpInstallationAddress");
                }

                if (String.IsNullOrEmpty(txtOrderRefNo.Text.Trim()) == true)
                {
                    ltrMessage.Text         = "Please enter the ARC Order Reference number.";
                    txtOrderRefNo.BackColor = System.Drawing.Color.Yellow;
                    txtOrderRefNo.Focus();

                    return;
                }
                else
                {
                    Session[enumSessions.OrderRef.ToString()] = txtOrderRefNo.Text;
                }

                if (IsValid)
                {
                    btnConfirmOrder.Enabled = false;
                    int    addressId             = 0;
                    int    installationAddressId = 0;
                    string contactno             = txtDeliContactNo.Text.ToString().Trim();
                    string OrderNo = String.Empty;
                    if (rdoInstallerAddress.Checked)
                    {
                        addressId = InstallerBAL.SaveInstallerAddress(Session[enumSessions.InstallerCompanyID.ToString()].ToString(), txtInstContactName1.Text, contactno, 0, "", "", "", "", "", "", Session[enumSessions.User_Name.ToString()].ToString());
                    }
                    else if (ddlarcdeliveryaddresses.SelectedValue != "0" && (chkEditAddress.Checked == false) && !string.IsNullOrEmpty(ddlarcdeliveryaddresses.SelectedValue))
                    {
                        addressId = Convert.ToInt32(ddlarcdeliveryaddresses.SelectedValue);
                    }
                    else
                    {
                        int countryId = 0;
                        int.TryParse(ddlCountry.SelectedValue, out countryId);
                        addressId = InstallerBAL.SaveInstallerAddress("", txtDeliContactName.Text, contactno, countryId, txtDeliAddressOne.Text, txtDeliAddressTwo.Text, txtDeliTown.Text, txtDeliCounty.Text, txtDeliPostcode.Text, ddlCountry.SelectedItem.Text, Session[enumSessions.User_Name.ToString()].ToString());
                    }

                    if (chkInstallationAddress.Checked)
                    {
                        instadd_differs = true;
                        int countryId = 0;
                        int.TryParse(ddlInstCountry.SelectedValue, out countryId);
                        installationAddressId = InstallerBAL.SaveInstallerAddress("", txtInstContactName.Text, txtInstContactNumber.Text, countryId,
                                                                                  txtInstAddressOne.Text, txtInstAddressTwo.Text, txtInstTown.Text,
                                                                                  txtInstCounty.Text, txtInstPostCode.Text, ddlInstCountry.SelectedItem.Text, Session[enumSessions.User_Name.ToString()].ToString());
                    }
                    //Added below code by Atiq on 11-08-2016 for ESI changes
                    string alarmDelArcCode = string.Empty;
                    if (ddlArcBranches.SelectedIndex > 0)
                    {
                        var arcData = (from a in db.AlarmDeliveryARCMappings
                                       where a.ID == Convert.ToInt32(ddlArcBranches.SelectedValue)
                                       select a.Branch_ARC_Code).SingleOrDefault();
                        alarmDelArcCode = arcData;
                    }
                    int orderid = Convert.ToInt32(Session[enumSessions.OrderId.ToString()].ToString());
                    var ordrNo  = db.USP_ConfirmOrderDetails(orderid, txtOrderRefNo.Text, Convert.ToDecimal(lblDeliveryTotal.Text), addressId,
                                                             ddlDeliveryTypes.SelectedValue == String.Empty ? 0 : Convert.ToInt32(ddlDeliveryTypes.SelectedValue), txtInstructions.Text,
                                                             VATRate, Session[enumSessions.User_Name.ToString()].ToString(), installationAddressId, txtInstContactName1.Text,
                                                             alarmDelArcCode).SingleOrDefault();
                    if (ordrNo != null)
                    {
                        OrderNo = ordrNo.OrderNo;
                    }
                    db.SubmitChanges();

                    int orderHasEmizonProducts = (from O in db.Orders
                                                  join
                                                  oi in db.OrderItems on O.OrderId equals oi.OrderId
                                                  join
                                                  p in db.Products on oi.ProductId equals p.ProductId
                                                  where
                                                  O.OrderId == orderid
                                                  &&
                                                  p.IsEmizonProduct == true
                                                  &&
                                                  p.ProductType == "Product"
                                                  select p.EM_ProductCode).Count();

                    // ** Send to logistcs
                    SendEmailDTO sendEmaildto = new SendEmailDTO();
                    sendEmaildto.ARCOrderRefNo       = txtOrderRefNo.Text;
                    sendEmaildto.orderDate           = lblOrderDate.Text;
                    sendEmaildto.userID              = Session[enumSessions.User_Id.ToString()].ToString();
                    sendEmaildto.userName            = Session[enumSessions.User_Name.ToString()].ToString();
                    sendEmaildto.userEmail           = Session[enumSessions.User_Email.ToString()].ToString();
                    sendEmaildto.orderID             = Session[enumSessions.OrderId.ToString()].ToString();
                    sendEmaildto.DdeliveryType       = ddlDeliveryTypes.SelectedItem.Text;
                    sendEmaildto.deliveryCost        = lblDeliveryTotal.Text;
                    sendEmaildto.installerID         = Session[enumSessions.InstallerCompanyID.ToString()].ToString();
                    sendEmaildto.specialInstructions = txtInstructions.Text;

                    //Send to CSL Orders INBOX // do not send to emizon queue as its internal email and EM is not mandatory
                    SendEmail.SendEmailWithPrice(OrderNo, mailTO, sendEmaildto, mailFrom, mailCC, false, false, 0);

                    // ** Send to customers
                    if (Session[enumSessions.User_Role.ToString()] != null && Session[enumSessions.User_Role.ToString()].ToString() == enumRoles.ARC_Admin.ToString())
                    {
                        SendEmail.SendEmailWithoutPrice(OrderNo, Session[enumSessions.User_Email.ToString()].ToString(), sendEmaildto,
                                                        mailFrom, mailCC + "," + LoadARCEmailCC(), false, (orderHasEmizonProducts > 0) ? true : false, orderid);
                    }
                    else
                    {
                        SendEmail.SendEmailWithPrice(OrderNo, Session[enumSessions.User_Email.ToString()].ToString(), sendEmaildto,
                                                     mailFrom, mailCC + "," + LoadARCEmailCC(), false, (orderHasEmizonProducts > 0) ? true : false, orderid);
                    }

                    db.Dispose();
                    Session[enumSessions.OrderId.ToString()]     = null;
                    Session[enumSessions.OrderNumber.ToString()] = OrderNo;

                    //Add Emizon page redirection here
                    if (orderHasEmizonProducts > 0)
                    {
                        Response.Redirect("OrderConfirmationEM.aspx?id=" + orderid.ToString());
                    }
                    else
                    {
                        Response.Redirect("OrderConfirmation.aspx");
                    }
                }
                else
                {
                    btnConfirmOrder.Enabled = true;
                    txtDeliContactName.Focus();
                    this.MaintainScrollPositionOnPostBack = false;
                }
            }
        }
        catch (System.Threading.ThreadAbortException ex)
        {
            //
        }
        catch (Exception objException)
        {
            CSLOrderingARCBAL.LinqToSqlDataContext db;
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "btnConfirmOrder_Click",
                                    Convert.ToString(objException.Message), Convert.ToString(objException.InnerException),
                                    Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress,
                                    false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
        }
    }
Exemplo n.º 4
0
    protected void Btnemail_Click(object sender, EventArgs e)
    {
        try
        {
            /////
            SendEmailDTO sendEmaildto = new SendEmailDTO();

            sendEmaildto.ARCOrderRefNo = lblARCOrderRefNo.Text;
            sendEmaildto.orderDate     = lblOrderDate.Text;
            sendEmaildto.userID        = hidUserID.Value;
            sendEmaildto.userName      = hidUserName.Value;
            sendEmaildto.userEmail     = hidUserEmail.Value;
            sendEmaildto.orderID       = Session[enumSessions.PreviousOrderId.ToString()].ToString();
            sendEmaildto.DdeliveryType = lblDelType.Text;
            sendEmaildto.deliveryCost  = lblDeliveryTotal.Text;
            sendEmaildto.installerID   = InstallerId;
            // sendEmaildto.InstallationAddId = InstallationAddId;
            sendEmaildto.specialInstructions = lblSpecialInst.Text;

            //  if(InstallationAddId!=0)
            // {
            //   sendEmaildto.instadd_differs = true;
            //}
            ////


            ApplicationDTO appdto;
            // Session[enumSessions.PreviousOrderId.ToString()]

            //commented as we are enetring it in cslorderingmeailtable
            //if (string.IsNullOrEmpty((string)HttpRuntime.Cache["smtphost"]))
            //{
            //    AppSettings appsett = new AppSettings();
            //    appdto = appsett.GetAppValues();
            //    smtphost = appdto.smtphost;
            //}
            //else
            //    smtphost = (string)HttpRuntime.Cache["smtphost"];


            if (string.IsNullOrEmpty((string)HttpRuntime.Cache["OrdersEmailFrom"]))
            {
                AppSettings appsett = new AppSettings();
                appdto   = appsett.GetAppValues();
                mailFrom = appdto.mailFrom;
            }
            else
            {
                mailFrom = (string)HttpRuntime.Cache["OrdersEmailFrom"];
            }


            if (string.IsNullOrEmpty((string)HttpRuntime.Cache["EmailCC"]))
            {
                AppSettings appsett = new AppSettings();
                appdto = appsett.GetAppValues();
                mailCC = appdto.mailCC;
            }
            else
            {
                mailCC = (string)HttpRuntime.Cache["EmailCC"];
            }


            if (string.IsNullOrEmpty((string)HttpRuntime.Cache["LogisticsEmail"]))
            {
                AppSettings appsett = new AppSettings();
                appdto = appsett.GetAppValues();
                mailTO = appdto.mailTO;
            }
            else
            {
                mailTO = (string)HttpRuntime.Cache["LogisticsEmail"];
            }


            SendEmail.SendEmailWithPrice(OrderNO, mailTO, sendEmaildto, mailFrom, mailCC, true, false, 0);

            if (rbtnwithoutprice.Checked == true)
            {
                SendEmail.SendEmailWithoutPrice(OrderNO, txtNewMail.Text.ToString(), sendEmaildto, mailFrom, mailCC, true, false, 0);
            }
            else
            {
                SendEmail.SendEmailWithPrice(OrderNO, txtNewMail.Text.ToString(), sendEmaildto, mailFrom, mailCC, true, false, 0);
            }
        }
        catch (Exception objException)
        {
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "Btnemail_Click", Convert.ToString(objException.Message),
                                    Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "",
                                    HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
        }
    }
Exemplo n.º 5
0
        public bool Send(SendEmailDTO emailDTO)
        {
            SmtpClient  smtpServer;
            MailMessage mailMessage;

            if (string.IsNullOrWhiteSpace(emailDTO.ToUserEmail))
            {
                throw new ArgumentNullException("ToUsreEmail");
            }

            if (string.IsNullOrWhiteSpace(emailDTO.EmailBodyText) && string.IsNullOrWhiteSpace(emailDTO.EmailBodyHtml))
            {
                throw new ArgumentNullException("EmailBodyText & EmailBodyHtml");
            }

            //Create SMTP client, the configration is in the web.config file, system.net/mailSettings/smtp
            smtpServer = new SmtpClient();
            //smtpServer.Host = WebConfigurationManager.AppSettings["SmtpHost"].ToString();

            //Generate Email Message based on passed in informatin
            mailMessage = new MailMessage();
            mailMessage.BodyTransferEncoding = TransferEncoding.Base64;
            mailMessage.BodyEncoding         = Encoding.UTF8;
            mailMessage.SubjectEncoding      = Encoding.UTF8;

            //If From Email is not , then setup the from email, else use the one from web.config system.net/mailSettings/smtp/from
            if (!string.IsNullOrWhiteSpace(emailDTO.FromUserEmail))
            {
                mailMessage.From = new MailAddress(emailDTO.FromUserEmail, emailDTO.FromUserDisplayName);
            }

            //To email
            if (!string.IsNullOrWhiteSpace(emailDTO.ToUserEmail))
            {
                mailMessage.To.Add(new MailAddress(emailDTO.ToUserEmail, emailDTO.ToUserDisplayName));
            }

            //if we have more recepins, add it here
            if (emailDTO.ToUsers != null && emailDTO.ToUsers.Count() > 0)
            {
                foreach (var item in emailDTO.ToUsers)
                {
                    mailMessage.To.Add(new MailAddress(item.Key, item.Value));
                }
            }

            //Add BCC emails
            if (!string.IsNullOrWhiteSpace(emailDTO.BccEmails))
            {
                mailMessage.Bcc.Add(emailDTO.BccEmails);
            }


            //Priority
            mailMessage.Priority = (MailPriority)emailDTO.MailPriority;

            //Email Subject
            if (!string.IsNullOrWhiteSpace(emailDTO.EmailSubject))
            {
                mailMessage.Subject = emailDTO.EmailSubject;
            }

            //Email Body
            //Text
            mailMessage.Body = emailDTO.EmailBodyText;

            //if contains HTML body , will use html body
            if (!string.IsNullOrWhiteSpace(emailDTO.EmailBodyHtml))
            {
                //mailMessage.Body = emailDTO.EmailBodyHtml;
                mailMessage.IsBodyHtml = true;

                AlternateView htmlBody = AlternateView.CreateAlternateViewFromString(emailDTO.EmailBodyHtml, Encoding.UTF8, MediaTypeNames.Text.Html);

                //Attach image
                if (emailDTO.ListLinkedResource != null && emailDTO.ListLinkedResource.Count() > 0)
                {
                    foreach (var res in emailDTO.ListLinkedResource)
                    {
                        if (res != null)
                        {
                            htmlBody.LinkedResources.Add(res);
                        }
                    }
                }
                mailMessage.AlternateViews.Add(htmlBody);
            }


            smtpServer.Send(mailMessage);

            return(true);
        }
Exemplo n.º 6
0
 public async Task <bool> SendMailAsync(SendEmailDTO emailDTO)
 {
     return(await Task.Run(() => Send(emailDTO)));
 }
Exemplo n.º 7
0
    public static void SendEmailWithPrice(string OrderNo, string mailTO, SendEmailDTO sendEmailDTO,
                                          string mailFrom, string mailCC, bool isEmailFromViewOrders, bool?hasEmizonProducts, int orderID)
    {
        try
        {
            String           ProductsList    = "";
            bool             instadd_differs = false;
            string           subjectsuffix   = string.Empty;
            string           templatePath    = "Template";
            SendEmailMessage sendEmail       = new SendEmailMessage();
            EmailMessage     cslEmailMessage = new EmailMessage();
            string           emizonQueuePath = ConfigurationManager.AppSettings["EmizonQueue"].ToString();//could have used AppSettings but no point as another one is using config

            string mailSubject = "Order Confirmation - Order Ref: " + OrderNo;
            if (isEmailFromViewOrders)
            {
                if (mailTO.EndsWith("@csldual.com"))
                {
                    subjectsuffix = "; Email Resent";
                }

                mailSubject  = mailSubject + subjectsuffix;
                templatePath = "../Template";
            }

            String        mailHtml   = ReadTemplates.ReadMailTemplate(System.Web.HttpContext.Current.Server.MapPath(templatePath), "EmailTemplate.html");
            StringBuilder objBuilder = new StringBuilder();
            objBuilder.Append(mailHtml);
            objBuilder.Replace("{OrderNo}", OrderNo);
            objBuilder.Replace("{OrderDate}", string.IsNullOrEmpty(sendEmailDTO.orderDate) ? "." : sendEmailDTO.orderDate);
            objBuilder.Replace("{OrderRef}", string.IsNullOrEmpty(sendEmailDTO.ARCOrderRefNo) ? "." : sendEmailDTO.ARCOrderRefNo);

            ARC    arc    = ArcBAL.GetArcInfoByUserId(new Guid(sendEmailDTO.userID));
            string arcAdd = "";

            if (arc != null)
            {
                arcAdd  = arc.CompanyName == null ? "" : arc.CompanyName + ",&nbsp;";
                arcAdd += arc.AddressOne + ", <br /> ";
                arcAdd += string.IsNullOrEmpty(arc.AddressTwo) ? "" : arc.AddressTwo + ",&nbsp;";
                arcAdd += string.IsNullOrEmpty(arc.Town) ? "" : arc.Town + ",<br /> ";
                arcAdd += string.IsNullOrEmpty(arc.County) ? "" : arc.County + ", ";
                arcAdd += string.IsNullOrEmpty(arc.PostCode) ? "" : arc.PostCode + " <br />";
                objBuilder.Replace("{Fax}", string.IsNullOrEmpty(arc.Fax) ? "." : arc.Fax);
                objBuilder.Replace("{Tel}", string.IsNullOrEmpty(arc.Telephone) ? "." : arc.Telephone);
                objBuilder.Replace("{ARC}", arcAdd);
            }

            objBuilder.Replace("{Username}", sendEmailDTO.userName);
            objBuilder.Replace("{UserEmail}", sendEmailDTO.userEmail);

            // OrderDetails
            LinqToSqlDataContext db = new LinqToSqlDataContext();
            var products            = db.USP_GetBasketProducts(Convert.ToInt32(sendEmailDTO.orderID)).ToList();

            if (products != null && products.Count > 0)
            {
                string chipNos     = "";
                int    countOption = 1;

                foreach (var prod in products)
                {
                    int rowCount = db.USP_GetBasketProductsOnCheckOut(Convert.ToInt32(sendEmailDTO.orderID)).Where(i => i.ProductCode == prod.ProductCode.Trim()).Count();
                    ProductsList += "<tr><td style=\"background: #FFF7F7\">" + prod.ProductCode + "</td><td>" + prod.ProductName + "</td> <td style=\"background: #FFF7F7\">" + prod.ProductQty + "</td><td>£" + prod.Price;

                    if (prod.ProductType == "Product")
                    {
                        chipNos = "";
                        var ChipNumbers = db.USP_GetBasketGPRSChipNumbersByProductId(Convert.ToInt32(sendEmailDTO.orderID), prod.ProductId, prod.CategoryId).ToList();

                        if (ChipNumbers != null)
                        {
                            foreach (var chipno in ChipNumbers)
                            {
                                chipNos += string.IsNullOrEmpty(chipno.GPRSNo) ? "" : chipno.GPRSNo + "-";
                                chipNos += string.IsNullOrEmpty(chipno.PSTNNo) ? "" : chipno.PSTNNo + "-";
                                chipNos += string.IsNullOrEmpty(chipno.GSMNo) ? "" : chipno.GSMNo + "-";  //added GSM NO(PanelID) in email
                                chipNos += string.IsNullOrEmpty(chipno.OptionName) ? "" : chipno.OptionName;
                                chipNos += ",";

                                if (chipno.PSTNNo == "" &&
                                    chipno.OptionName == "" &&
                                    chipno.GSMNo == "" &&
                                    chipNos.Length > 0
                                    )//added GSM NO(PanelID) in email
                                {
                                    chipNos = chipNos.Remove(chipNos.Length - 1, 1);
                                }
                            }


                            if (chipNos != "")
                            {
                                chipNos       = chipNos.Substring(0, chipNos.Length - 1);
                                ProductsList += "</td> <td style=\"background: #FFF7F7\">" + chipNos + "</td> </td></tr>";
                            }
                            else
                            {
                                ProductsList += "</td> <td style=\"background: #FFF7F7\">Chip Numbers : Not Provided</td></tr>";
                            }
                        }

                        if (rowCount == 1)
                        {
                            var dependentproducts = db.USP_GetBasketDependentProductsByProductId(Convert.ToInt32(sendEmailDTO.orderID), prod.ProductId, prod.CategoryId).ToList();
                            if (dependentproducts != null && dependentproducts.Count > 0)
                            {
                                foreach (var dp in dependentproducts)
                                {
                                    ProductsList += "<tr><td>" + dp.ProductCode + "</td><td>" + dp.ProductName + "</td><td>" + dp.ProductQty + "</td><td>£" + dp.Price + "</tr>";
                                }
                            }
                            countOption = 0;
                        }
                        else if (rowCount == countOption)
                        {
                            var dependentproducts = db.USP_GetBasketDependentProductsByProductId(Convert.ToInt32(sendEmailDTO.orderID), prod.ProductId, prod.CategoryId).ToList();
                            if (dependentproducts != null && dependentproducts.Count > 0)
                            {
                                foreach (var dp in dependentproducts)
                                {
                                    ProductsList += "<tr><td>" + dp.ProductCode + "</td><td>" + dp.ProductName + "</td><td>" + dp.ProductQty + "</td><td>£" + dp.Price + "</tr>";
                                }
                            }
                        }
                    }
                    countOption++;
                }
            }

            OrderDTO objorder = CSLOrderingARCBAL.BAL.OrdersBAL.GetOrderDetail(Convert.ToInt32(sendEmailDTO.orderID));
            //objBuilder.Replace("{OrderTotal}", Convert.ToDecimal(lblDtlsOrderTotal.Text).ToString("c"));
            objBuilder.Replace("{OrderTotal}", "£" + Convert.ToDecimal(objorder.OrderTotal));
            //objBuilder.Replace("{DeliveryTotal}", Convert.ToDecimal(lblDtlsDeliveryTotal.Text).ToString("c"));
            objBuilder.Replace("{DeliveryTotal}", "£" + Convert.ToDecimal(objorder.DeliveryCost));
            //objBuilder.Replace("{VAT}", Convert.ToDecimal(lblDtlsVAT.Text).ToString("c"));
            objBuilder.Replace("{VAT}", "£" + Convert.ToDecimal(objorder.VATAmount));
            //objBuilder.Replace("{TotalToPay}", Convert.ToDecimal(lblDtlsTotalToPay.Text).ToString("c"));
            objBuilder.Replace("{TotalToPay}", "£" + Convert.ToDecimal(objorder.TotalAmountToPay));
            objBuilder.Replace("{DeliveryTypeName}", string.IsNullOrEmpty(sendEmailDTO.DdeliveryType) ? "" : sendEmailDTO.DdeliveryType);
            objBuilder.Replace("{DeliveryTypePrice}", "£" + sendEmailDTO.deliveryCost);
            objBuilder.Replace("{Installer}", InstallerBAL.GetAddressHTML2LineForEmail(new Guid(sendEmailDTO.installerID)));

            if (objorder.InstallationAddressId > 0)
            {
                instadd_differs = true;
            }
            else
            {
                instadd_differs = false;
            }
            if (instadd_differs)// || sendEmailDTO.InstallationAddId != 0)
            {
                //string InsAdd = InstallerBAL.GetAddressHTML2LineForEmail(Convert.ToInt32(Session[enumSessions.PreviousOrderId.ToString()].ToString()));
                string InsAdd = objorder.InstallationAddressId.HasValue ? InstallerBAL.GetAddressHTML2LineForEmail(objorder.InstallationAddressId.Value) : "Not Available";
                objBuilder.Replace("{InstallerAddress}", "<td><div style=\"width: 100%; margin: 0; padding: 0;\"><table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\"><tr><td style=\"text-align: left\"> <font color=\"#888\" size=\"2\" face=\"Arial\">" + InsAdd + " </font></td></tr></table></div></td>");
                objBuilder.Replace("{HeadingInstallerAdd}", "<td><h3 style=\"font-size:11px; text-align: center; margin: 0; padding: 5px auto;\">Installation Address</h3></td>");
            }
            else
            {
                objBuilder.Replace("{InstallerAddress}", "");
                objBuilder.Replace("{HeadingInstallerAdd}", "");
            }
            objBuilder.Replace("{DeliveredTo}", OrdersBAL.GetDeliveryAddressHTML2Line(Convert.ToInt32(sendEmailDTO.orderID)));
            objBuilder.Replace("{SpecialInstructions}", sendEmailDTO.specialInstructions);
            if (isEmailFromViewOrders)
            {
                objBuilder.Append("Email Resent");
            }
            var distinctProduct = products.Select(i => i.ProductCode).Distinct();

            foreach (var pro in distinctProduct)
            {
                products = db.USP_GetBasketProducts(Convert.ToInt32(sendEmailDTO.orderID)).Where(p => p.ProductCode == pro).Take(1).ToList();

                foreach (var prod in products)
                {
                    if (prod.IsCSDUser == true)
                    {
                        ProductsList += "<tr><td>" + prod.ProductCode + "</td><td>" + prod.Message + "</td></tr>";
                    }
                }
            }
            objBuilder.Replace("{ProductList}", ProductsList);
            if (mailTO != "" && mailTO.Trim() != "")
            {
                string[] mailFromList = mailFrom.Split(',');
                string[] mailCCList   = mailCC.Split(',');
                string   emailCC      = string.Empty;

                foreach (string email in mailCCList)
                {
                    emailCC += email + ",";
                }
                if (!string.IsNullOrEmpty(emailCC))
                {
                    emailCC = emailCC.TrimEnd(',');
                }


                //PUSH TO EMIZON QUEUE
                if (hasEmizonProducts.HasValue && hasEmizonProducts.Value)
                {
                    EmizonOrderController.AddAPIRequestToQueue(emizonQueuePath, new Emizon.APIModels.MSMQTypes.QueueOrderMessage()
                    {
                        From          = mailFrom,
                        To            = mailTO,
                        CC            = mailCC,
                        BCC           = mailCC,
                        Subject       = mailSubject,
                        OrderHTMLBody = objBuilder.ToString(),
                        orderID       = orderID
                    });
                }
                else
                {
                    //Add below code to send the email message via msmq not smtp -Priya 15/06/2017
                    //Remove Emizon placeholder
                    objBuilder.Replace("{EmizonData}", "");

                    cslEmailMessage.From    = mailFrom;
                    cslEmailMessage.To      = mailTO;
                    cslEmailMessage.CC      = emailCC;
                    cslEmailMessage.BCC     = emailCC;
                    cslEmailMessage.Subject = mailSubject;
                    cslEmailMessage.Message = objBuilder.ToString();

                    sendEmail.SendEmailMessageToQueue(ConfigurationManager.AppSettings["QueueName"].ToString(), cslEmailMessage);
                }
                //End Code sending email  to msmq.
            }
            ApplicationDTO appSettings     = new AppSettings().GetAppValues();
            List <string>  lstProductCodes = new List <string>();
            lstProductCodes = appSettings.ConnectionOnlyCodes.Split(',').ToList();

            bool connectionProductCodeExist = false;
            foreach (var x in distinctProduct)
            {
                if (lstProductCodes.Exists(e => e.EndsWith(x)))
                {
                    connectionProductCodeExist = true;
                }
            }
            StringBuilder strURL = new StringBuilder();

            if (connectionProductCodeExist)
            {
                #region buildURLs

                List <DCCCompany> lstDCCCompany = db.DCCCompanies.ToList();

                foreach (DCCCompany company in lstDCCCompany)
                {
                    var tableCodes = company.Productcode.Split(',').ToList();

                    foreach (string s in tableCodes)
                    {
                        if (distinctProduct.Contains(s)) //only create a link if the product exist in the basket items.
                        {
                            strURL.Append(" please <a href='" + company.InstructionsUrl + "'>Click here for " + company.company_name + "</a> or ");
                            break; // once we add
                        }
                    }
                }


                #endregion


                string mailSubjectConnectionOnly = "ARC Connection Only - Order Confirmation - Order Ref: " + OrderNo;
                if (isEmailFromViewOrders)
                {
                    if (mailTO.EndsWith("@csldual.com"))
                    {
                        subjectsuffix = "; Email Resent";
                    }

                    mailSubjectConnectionOnly = mailSubjectConnectionOnly + subjectsuffix;
                }

                String mailHtmlConnectionOnly = ReadTemplates.ReadMailTemplate(System.Web.HttpContext.Current.Server.MapPath(templatePath), "EmailTemplate_ConnectionOrders.html");
                //  String mailHtmlConnectionOnly = ReadTemplates.ReadMailTemplate(System.Web.HttpContext.Current.Server.MapPath(templatePath), "EmailTemplate_v2_ConnectionOrders.html");
                StringBuilder objBuilderConnectionOnly = new StringBuilder();
                objBuilderConnectionOnly.Append(mailHtmlConnectionOnly);

                objBuilderConnectionOnly.Replace("{InstallationURL}", strURL.ToString().TrimEnd(' ', 'o', 'r') + '.');
                objBuilderConnectionOnly.Replace("{OrderNo}", OrderNo);
                objBuilderConnectionOnly.Replace("{OrderDate}", sendEmailDTO.orderDate);
                objBuilderConnectionOnly.Replace("{OrderRef}", string.IsNullOrEmpty(sendEmailDTO.ARCOrderRefNo) ? "." : sendEmailDTO.ARCOrderRefNo);
                objBuilderConnectionOnly.Replace("{OrderTotal}", "£" + objorder.OrderTotal);
                objBuilderConnectionOnly.Replace("{DeliveryTotal}", "£" + objorder.DeliveryCost);
                objBuilderConnectionOnly.Replace("{VAT}", "£" + objorder.VATAmount);
                objBuilderConnectionOnly.Replace("{TotalToPay}", "£" + objorder.TotalAmountToPay);
                objBuilderConnectionOnly.Replace("{DeliveryTypeName}", sendEmailDTO.DdeliveryType.ToString().TrimEnd(' '));
                // objBuilderConnectionOnly.Replace("{DeliveryTypePrice}", "£" + sendEmailDTO.deliveryCost);
                objBuilderConnectionOnly.Replace("{Installer}", InstallerBAL.GetAddressHTML2LineForEmail(new Guid(sendEmailDTO.installerID)));


                if (arc != null)
                {
                    objBuilderConnectionOnly.Replace("{Fax}", string.IsNullOrEmpty(arc.Fax) ? "." : arc.Fax);
                    objBuilderConnectionOnly.Replace("{Tel}", string.IsNullOrEmpty(arc.Telephone) ? "." : arc.Telephone);
                    objBuilderConnectionOnly.Replace("{ARC}", arcAdd);
                }

                objBuilderConnectionOnly.Replace("{Username}", sendEmailDTO.userName);
                objBuilderConnectionOnly.Replace("{UserEmail}", sendEmailDTO.userEmail);

                //comment below line if new RAc connection only template is approved
                if (instadd_differs)
                {
                    string InsAddConnection = objorder.InstallationAddressId.HasValue ? InstallerBAL.GetAddressHTML2LineForEmail(objorder.InstallationAddressId.Value) : "Not Available";
                    //string InsAddConnection= InstallerBAL.GetInstallationAddressHTML2LineForEmail(Convert.ToInt32(Session[enumSessions.OrderId.ToString()].ToString()));
                    objBuilderConnectionOnly.Replace("{InstallerAddress}", "<td><div style=\"width: 100%; margin: 0; padding: 0;\"><table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\"><tr><td style=\"text-align: left\"> <font color=\"#888\" size=\"2\" face=\"Arial\">" + InsAddConnection + " </font></td></tr></table></div></td>");
                    objBuilderConnectionOnly.Replace("{HeadingInstallerAdd}", "<td><h3 style=\"font-size:11px; text-align: center; margin: 0; padding: 5px auto;\">Installation Address</h3></td>");
                }
                else
                {
                    //objBuilderConnectionOnly.Replace("{InstallerAddress}", "");
                    // objBuilderConnectionOnly.Replace("{HeadingInstallerAdd}", "");
                    objBuilderConnectionOnly.Replace("{InstallerAddress}", "");
                    objBuilderConnectionOnly.Replace("{HeadingInstallerAdd}", "");
                }

                //

                objBuilderConnectionOnly.Replace("{DeliveredTo}", OrdersBAL.GetDeliveryAddressHTML2Line(Convert.ToInt32(sendEmailDTO.orderID)));
                objBuilderConnectionOnly.Replace("{SpecialInstructions}", string.IsNullOrEmpty(sendEmailDTO.specialInstructions.Trim()) ? "." : sendEmailDTO.specialInstructions.Trim());

                ProductsList = Regex.Replace(ProductsList, @"(?i)<(table|tr|td)(?:\s+(?:""[^""]*""|'[^']*'|[^""'>])*)?>", "<$1>");
                objBuilderConnectionOnly.Replace("{ProductList}", ProductsList);

                LinqToSqlDataContext dbe = new LinqToSqlDataContext();
                var connInstallerEmail   = (from o in dbe.Orders
                                            join i in dbe.Installers on o.InstallerUnqCode equals i.UniqueCode.ToString()
                                            join ia in dbe.InstallerAddresses on i.AddressID equals ia.AddressID
                                            where o.OrderNo == OrderNo
                                            select ia.Email).Single();

                if (string.IsNullOrEmpty(connInstallerEmail))
                {
                    connInstallerEmail = ConfigurationManager.AppSettings["TeleSalesEmail"].ToString();
                }
                cslEmailMessage.From    = mailFrom;
                cslEmailMessage.To      = connInstallerEmail;
                cslEmailMessage.CC      = mailCC;
                cslEmailMessage.BCC     = mailCC;
                cslEmailMessage.Subject = mailSubjectConnectionOnly;
                cslEmailMessage.Message = Convert.ToString(objBuilderConnectionOnly.ToString());

                sendEmail.SendEmailMessageToQueue(ConfigurationManager.AppSettings["QueueName"].ToString(), cslEmailMessage);
            }

            db.Dispose();
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        catch (Exception objException)
        {
            CSLOrderingARCBAL.LinqToSqlDataContext db;
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(System.Web.HttpContext.Current.Request.Url.ToString(), "SendEmailWithPrice",
                                    Convert.ToString(objException.Message), Convert.ToString(objException.InnerException),
                                    Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false,
                                    Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
        }
    }