Пример #1
0
        public async Task <bool> SendCustomerOTP(int OTP, string Email)
        {
            bool sendsuccess = false;

            try
            {
                Mail _mail = new Mail();
                using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/PartyEcTemplates/SendOtp.html")))
                {
                    _mail.Body = reader.ReadToEnd();
                }
                _mail.Body       = _mail.Body.Replace("{Otp}", OTP.ToString());
                _mail.IsBodyHtml = true;
                _mail.Subject    = "OTP";
                _mail.To         = Email;
                sendsuccess      = await _mailBusiness.MailSendAsync(_mail);

                //quotationsObj.EventsLogViewObj.CustomerNotifiedYN = Mailstatus;
            }
            catch (Exception ex)
            {
                throw ex;
                //return sendsuccess;
            }
            return(sendsuccess);
        }
Пример #2
0
        public async Task <bool> SendApprolMails(Guid documentID, string documentType)
        {
            try
            {
                DocumentApprovalMailDetail docAprovalMailDetail = new DocumentApprovalMailDetail();
                bool     sendsuccess;
                string   link;
                string   loginLink = WebConfigurationManager.AppSettings["AppURL"];
                Settings settings  = new Settings();
                docAprovalMailDetail = _documentApprovalRepository.GetApprovalMailDetails(documentID, documentType);
                if (docAprovalMailDetail != null)
                {
                    link = WebConfigurationManager.AppSettings["AppURL"] + "/DocumentApproval/ViewPendingDocuments?ID=" + docAprovalMailDetail.ApprovalID + "&DocType=" + documentType + "&DocID=" + documentID;
                    if (docAprovalMailDetail.Status == "PENDING")
                    {
                        string mailBody = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/MailTemplate/SendForApproval.html"));

                        string imgLink = WebConfigurationManager.AppSettings["AppURL"] + "/Content/images/Pilot1.png";

                        Mail mail = new Mail();
                        mail.Body    = mailBody.Replace("$DocumentType$", docAprovalMailDetail.DocumentType).Replace("$DocumentNo$", docAprovalMailDetail.DocumentNo).Replace("$DocumentOwner$", docAprovalMailDetail.DocumentOwner).Replace("$Name$", docAprovalMailDetail.NextApprover).Replace("$ApproveLink$", link).Replace("$Date$", _pSASysCommon.GetCurrentDateTime().ToString(settings.DateFormat)).Replace("$LoginLink$", loginLink).Replace("$Logo$", imgLink);
                        mail.Subject = "Document Pending For Approval (" + docAprovalMailDetail.DocumentNo + ")";
                        mail.To      = docAprovalMailDetail.NextApproverEmail;
                        sendsuccess  = await _mailBusiness.MailSendAsync(mail);
                    }

                    if (docAprovalMailDetail.Status == "REJECTED")
                    {
                        string mailBody = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/MailTemplate/DocumentRejected.html"));
                        string imgLink  = WebConfigurationManager.AppSettings["AppURL"] + "/Content/images/Pilot1.png";
                        Mail   mail     = new Mail();
                        mail.Body    = mailBody.Replace("$DocumentType$", docAprovalMailDetail.DocumentType).Replace("$DocumentNo$", docAprovalMailDetail.DocumentNo).Replace("$Name$", docAprovalMailDetail.DocumentOwner).Replace("$Date$", _pSASysCommon.GetCurrentDateTime().ToString(settings.DateFormat)).Replace("$LoginLink$", loginLink).Replace("$Approver$", docAprovalMailDetail.NextApprover).Replace("$Remarks$", docAprovalMailDetail.Remarks).Replace("$Logo$", imgLink);
                        mail.Subject = "Document Rejected for ammedment (" + docAprovalMailDetail.DocumentNo + ")";
                        mail.To      = docAprovalMailDetail.DocumnetOwnerMail;
                        sendsuccess  = await _mailBusiness.MailSendAsync(mail);
                    }

                    if (docAprovalMailDetail.Status == "APPROVED")
                    {
                        string mailBody = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/MailTemplate/DocumentApproved.html"));
                        string imgLink  = WebConfigurationManager.AppSettings["AppURL"] + "/Content/images/Pilot1.png";
                        Mail   mail     = new Mail();
                        mail.Body    = mailBody.Replace("$DocumentType$", docAprovalMailDetail.DocumentType).Replace("$DocumentNo$", docAprovalMailDetail.DocumentNo).Replace("$Name$", docAprovalMailDetail.DocumentOwner).Replace("$Date$", _pSASysCommon.GetCurrentDateTime().ToString(settings.DateFormat)).Replace("$LoginLink$", loginLink).Replace("$Remarks$", docAprovalMailDetail.Remarks).Replace("$Logo$", imgLink);
                        mail.Subject = "Document Approved (" + docAprovalMailDetail.DocumentNo + ")";
                        mail.To      = docAprovalMailDetail.DocumnetOwnerMail;
                        sendsuccess  = await _mailBusiness.MailSendAsync(mail);
                    }
                }


                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #3
0
        //public async Task<bool> albertMail(Notification notification)
        //{
        //    try
        //    {
        //        string EmailFromAddress = System.Web.Configuration.WebConfigurationManager.AppSettings["EmailFromAddress"];
        //        string smtpUserName = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-UserName"];
        //        string smtpPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-Password"];
        //        string myport = System.Web.Configuration.WebConfigurationManager.AppSettings["Port"];
        //        var from = new MailAddress(EmailFromAddress, "Admin_@_PartyEC");
        //        var to = new MailAddress("*****@*****.**");
        //        var useDefaultCredentials = true;
        //        var enableSsl = false;
        //      //  var replyto = "*****@*****.**"; // set here your email;
        //        var userName = smtpUserName;
        //        var password = smtpPassword;
        //        var port = int.Parse(myport);
        //        var host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"];
        //        userName = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-UserName"];  // setup here the username;
        //        password = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-Password"]; // setup here the password;
        //        bool.TryParse("true", out useDefaultCredentials); //setup here if it uses defaault credentials
        //        bool.TryParse("true", out enableSsl); //setup here if it uses ssl
        //       // int.TryParse(myport, out port); //setup here the port
        //        host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"]; //setup here the host

        //        using (var mail = new MailMessage(from, to))
        //        {
        //            mail.Subject = "testing mail by albert";
        //            mail.Body = "<table><tr>Thrithavam from table</tr></table>";
        //            mail.IsBodyHtml = true;

        //           // mail.ReplyToList.Add(new MailAddress(replyto, "*****@*****.**"));
        //            mail.ReplyToList.Add(from);
        //            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Delay |
        //                                               DeliveryNotificationOptions.OnFailure |
        //                                               DeliveryNotificationOptions.OnSuccess;
        //            using (var client = new SmtpClient())
        //            {
        //                client.Host = host;
        //                client.Port = int.Parse(myport);
        //                client.EnableSsl = enableSsl;
        //                client.UseDefaultCredentials = useDefaultCredentials;
        //                client.DeliveryMethod = SmtpDeliveryMethod.Network;
        //               // client.Credentials=
        //                if (!client.UseDefaultCredentials && !string.IsNullOrEmpty(userName) &&
        //                    !string.IsNullOrEmpty(password))
        //                {
        //                    client.Credentials = new NetworkCredential(userName, password);
        //                }
        //                client.Credentials = new NetworkCredential(userName, password);
        //                await client.SendMailAsync(mail);
        //            }
        //        }
        //    }
        //    catch(Exception ex)
        //    {

        //    }
        //    return true;

        //}


        //public async Task<bool> albertMail(Notification notification)
        //{
        //    try
        //    {
        //        string EmailFromAddress = System.Web.Configuration.WebConfigurationManager.AppSettings["EmailFromAddress"];
        //        string host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"];
        //        string smtpUserName = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-UserName"];
        //        string smtpPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-Password"];
        //        string port = System.Web.Configuration.WebConfigurationManager.AppSettings["Port"];
        //        var from = new MailAddress(EmailFromAddress, "Admin_@_PartyEC");
        //        var to = new MailAddress("*****@*****.**");
        //        // var useDefaultCredentials = true;
        //        var enableSsl = false;
        //        //  var replyto = "*****@*****.**"; // set here your email;
        //        //  bool.TryParse("true", out useDefaultCredentials); //setup here if it uses defaault credentials
        //        bool.TryParse("true", out enableSsl); //setup here if it uses ssl
        //        // int.TryParse(myport, out port); //setup here the port
        //        // host = System.Web.Configuration.WebConfigurationManager.AppSettings["SMTP-host"]; //setup here the host
        //        using (var mail = new MailMessage(from, to))
        //        {
        //            mail.Subject = "ATTN";
        //            mail.Body = "wonderfull after ge";
        //            mail.IsBodyHtml = true;

        //            // mail.ReplyToList.Add(new MailAddress(replyto, "*****@*****.**"));
        //          //  mail.ReplyToList.Add(from);
        //            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Delay |
        //                                               DeliveryNotificationOptions.OnFailure |
        //                                               DeliveryNotificationOptions.OnSuccess;
        //            using (var client = new SmtpClient())
        //            {
        //                client.Host = host;
        //                client.Port = int.Parse(port);
        //                client.EnableSsl = enableSsl;
        //                //client.UseDefaultCredentials = useDefaultCredentials;
        //                client.DeliveryMethod = SmtpDeliveryMethod.Network;
        //                // client.Credentials=
        //                //if (!client.UseDefaultCredentials && !string.IsNullOrEmpty(smtpUserName) &&
        //                //    !string.IsNullOrEmpty(password))
        //                //{
        //                //    client.Credentials = new NetworkCredential(smtpUserName, smtpPassword);
        //                //}
        //                client.Credentials = new NetworkCredential(smtpUserName, smtpPassword);
        //                await client.SendMailAsync(mail);
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return false;
        //    }
        //    return true;

        // }

        public async Task <bool> NotificationEmailPush(Notification notification)
        {
            bool sendsuccess = false;

            try
            {
                //Get customer information
                OperationsStatus opstatus = new OperationsStatus();
                Customer         customer = null;
                customer = _customerBusiness.GetCustomer(notification.customer.ID, opstatus);

                Mail _mail = new Mail();
                using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/PartyEcTemplates/Notifications.html")))
                {
                    _mail.Body = reader.ReadToEnd();
                }
                _mail.Body    = _mail.Body.Replace("{CustomerName}", customer.Name);
                _mail.Body    = _mail.Body.Replace("{Message}", notification.Message);
                _mail.Subject = notification.Title;
                _mail.To      = customer.Email;
                sendsuccess   = await _mailBusiness.MailSendAsync(_mail);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(sendsuccess);
        }
Пример #4
0
        public async Task <bool> QuotationEmail(Quotations quotationsObj)
        {
            bool sendsuccess = false;

            try
            {
                if (quotationsObj.customerObj.Email != "")
                {
                    Mail _mail = new Mail();
                    using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/PartyEcTemplates/Quotation.html")))
                    {
                        _mail.Body = reader.ReadToEnd();
                    }
                    _mail.Body       = _mail.Body.Replace("{CustomerName}", quotationsObj.customerObj.Name);
                    _mail.Body       = _mail.Body.Replace("{QuotationDate}", quotationsObj.QuotationDate);
                    _mail.Body       = _mail.Body.Replace("{ProductName}", quotationsObj.ProductName);
                    _mail.Body       = _mail.Body.Replace("{QuotationNo}", quotationsObj.QuotationNo);
                    _mail.Body       = _mail.Body.Replace("{RequiredDate}", quotationsObj.RequiredDate);
                    _mail.Body       = _mail.Body.Replace("{Qty}", quotationsObj.Qty.ToString());
                    _mail.Body       = _mail.Body.Replace("{Price}", quotationsObj.Price.ToString());
                    _mail.Body       = _mail.Body.Replace("{tax}", quotationsObj.TaxAmt.ToString());
                    _mail.Body       = _mail.Body.Replace("{additionalCharges}", quotationsObj.AdditionalCharges.ToString());
                    _mail.Body       = _mail.Body.Replace("{discount}", quotationsObj.DiscountAmt.ToString());
                    _mail.Body       = _mail.Body.Replace("{subTotal}", quotationsObj.SubTotal.ToString());
                    _mail.Body       = _mail.Body.Replace("{grandTotal}", quotationsObj.GrandTotal.ToString());
                    _mail.Body       = _mail.Body.Replace("{Status}", quotationsObj.StatusText.ToString());
                    _mail.IsBodyHtml = true;
                    _mail.Subject    = "Quotation No:" + quotationsObj.QuotationNo;
                    _mail.To         = quotationsObj.customerObj.Email;
                    sendsuccess      = await _mailBusiness.MailSendAsync(_mail);

                    //quotationsObj.EventsLogViewObj.CustomerNotifiedYN = Mailstatus;
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //return sendsuccess;
            }
            return(sendsuccess);
        }