private void sentRMATOCustomer(string RmaId)
        {
            var ramIdC   = Convert.ToInt32(RmaId);
            var rmaTrack = GetCreditNoteIdFromRAMTracking(ramIdC);


            String     strConnectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            ContactDAL cdal               = new ContactDAL(strConnectionString);
            var        orderDal           = new OrderDAL(strConnectionString);
            var        creditNoteDal      = new CreditNotesDAL(strConnectionString);
            var        ordersendEmail     = new OrderSendEmailDAL(strConnectionString);
            var        creditNoteObj      = creditNoteDal.getCreditNoteObj(rmaTrack.CreditNoteID);
            var        creditEmailHandler = new CreditNoteRMAHandler(strConnectionString);

            if (creditNoteObj.IsAvail)
            {
                if (creditNoteObj.Reason == "CHANGED PRINTER")
                {
                    var contactId = Convert.ToInt32(creditNoteObj.ContactId);
                    var contact   = cdal.GetContactByContactId(contactId);
                    if (!string.IsNullOrEmpty(creditNoteObj.Reason))
                    {
                        var orderID            = Convert.ToInt32(creditNoteObj.OrderId);
                        var xeroOrderDTSnumber = orderDal.getXeroDTSID(orderID);
                        var subject            = "RMA Request for " + creditNoteObj.Reason;

                        var body = "Hi , <br/>  RMA Request  for this order number :"
                                   + xeroOrderDTSnumber;
                        if (!string.IsNullOrEmpty(rmaTrack.SupplierRMANumber))
                        {
                            body = body + "<br/> Supplier RMA number " + rmaTrack.SupplierRMANumber;
                        }
                        if (!string.IsNullOrEmpty(rmaTrack.TrackingNumber))
                        {
                            body = body + " <br/> TrackingNumber  " + rmaTrack.TrackingNumber;
                        }

                        var toEmail = contact.Email;

                        var from     = "*****@*****.**";
                        var fromName = "Deltonesolutions";

                        var res = creditEmailHandler.SendCreditNoteEmail(rmaTrack.CreditNoteID, "", "", from, fromName, toEmail,
                                                                         "", "", subject, body, true, null);

                        if (res)
                        {
                            creditEmailHandler.UpdateRMISentToCustomer(rmaTrack.CreditNoteID);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private static void SendEmailToSupplier(RMAResult filesAndSupp)
        {
            string cs           = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            var    subject      = "RMA Request from Deltone Solutions ";
            String bottomBanner = "<img src=\"cid:bottombanner\" height='105' width='550'>";

            var bodytitle          = "Hi  , <br/> Please fill RMA for all attached orders and send back to Deltone Solutions.";
            var creditEmailHandler = new CreditNoteRMAHandler(cs);
            var typeEmail          = 2; //RMA Request Email
            //    var suppEmails = new OrderSendEmailDAL(cs).GetSupplierEmails(suppName, typeEmail);
            var body = CreateEmailTemplateForSupplier(bottomBanner, bodytitle);

            var filePath  = "C:\\inetpub\\wwwroot\\DeltoneCRM\\Uploads\\RMA\\";
            var from      = "*****@*****.**";
            var fromName  = "Deltonesolutions";
            var sendEmail = new EmailSender();

            if (filesAndSupp.FilesAndSuppNames != null)
            {
                foreach (var item in filesAndSupp.FilesAndSuppNames)
                {
                    var suppEmails = new OrderSendEmailDAL(cs).GetSupplierEmails(item.Key, typeEmail);
                    var fileName   = item.Value + ".csv";
                    foreach (var sEmail in suppEmails)
                    {
                        var fileAtta     = new System.Collections.Generic.List <Attachment>();
                        var fileFullPAth = filePath + fileName;
                        if (File.Exists(fileFullPAth))
                        {
                            System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(fileFullPAth);
                            attachment.Name = Path.GetFileName(fileFullPAth);
                            fileAtta.Add(attachment);
                        }
                        sendEmail.SendEmailAlternativeView(from, fromName, sEmail.SupplierEmailAddress,
                                                           "*****@*****.**", "", subject, body, true, fileAtta);
                    }
                }
            }

            if (filesAndSupp.RMAIDS != null)
            {
                if (filesAndSupp.RMAIDS.Count() > 0)
                {
                    foreach (var id in filesAndSupp.RMAIDS)
                    {
                        UpdateRMACreditXeroInfo(id);
                    }
                }
            }
        }