private void SendEmail_ConfirmDocument_WaitForFinanceConfirm(ConfirmDocument confirmDoc)
        {
            const string subject = "LC approved";
            var          message = new RazorMailMessage("ConfirmDocument/Confirmed", confirmDoc).Render();

            SendEmail("bank@localhost", subject, message);
        }
Esempio n. 2
0
 public static void SendEmail(string[] to, string subject, RazorMailMessage message)
 {
     Mailer.UseMessage(message)
     .From("*****@*****.**")
     .To(to)
     .Subject(subject)
     .SendAsync();
 }
Esempio n. 3
0
 protected void SendEmail(string from, string to, string subject, RazorMailMessage message)
 {
     Mailer.UseMessage(message)
     .From(from)
     .To(to)
     .Subject(subject)
     .SendAsync();
 }
Esempio n. 4
0
 public static void SendEmailHaveAttach(string to, string subject, RazorMailMessage message, string attachName, byte[] data)
 {
     Mailer.UseMessage(message)
     .From("*****@*****.**")
     .To(to)
     .Subject(subject)
     .Attach(attachName, data)
     .SendAsync();
 }
        public ActionResult TestMail()
        {
            string subject = "Test mail " + DateTime.Now.ToString("dd-MMM-yyyy HH:mm");
            var    obj     = new object();
            var    message = new RazorMailMessage("Logs/Exception", obj).Render();

            EmailHelper.SendEmail(new[] { "*****@*****.**" }, subject, message);
            return(Json("Successfully!", JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
 private void SendEmail_IndentCancelled(Indent indent)
 {
     string subject = "Indent no " + indent.IndentNo + " has been cancelled";
     var message = new RazorMailMessage("Indent/Cancelled", indent).Render();
     //IEnumerable<User> users = MembershipService.GetUsersInRole("Indent Manager");
     IEnumerable<User> users = MembershipService.GetAllUserOfEmailTemplate("Indent", "Cancelled");
     foreach (User u in users.Where(m => m.Email != null))
     {
         SendEmail(u.Email, subject, message);
     }
 }
        private void SendEmail_ConfirmDocument_Archived(ConfirmDocument confirmDoc)
        {
            const string subject = "LC is denied";
            var          message = new RazorMailMessage("ConfirmDocument/Denied", confirmDoc).Render();
            //IEnumerable<User> users = MembershipService.GetUsersInRole("General Manager");
            IEnumerable <User> users = MembershipService.GetAllUserOfEmailTemplate("ConfirmDocument", "Denied");

            foreach (User u in users.Where(f => !string.IsNullOrWhiteSpace(f.Email)))
            {
                SendEmail(u.Email, subject, message);
            }
        }
Esempio n. 8
0
        private void LogsSendEmail(Audit audit)
        {
            string subject      = "CPO System Logs Exception " + HttpContext.Current.Request.Url.Host;
            var    message      = new RazorMailMessage("Logs/Exception", audit).Render();
            var    receiveEmail = ConfigurationManager.AppSettings["LogsEmail"];

            if (receiveEmail != null && !string.IsNullOrEmpty(receiveEmail))
            {
                var emails = receiveEmail.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
                EmailHelper.SendEmail(emails, subject, message);
            }
        }
Esempio n. 9
0
        // indent user / manager / general manager -> all
        private void SendEmail_ConsolidateCancelled(Consolidate consolidate)
        {
            string subject = "Consolidate cancelled (id :" + consolidate.ID + ")";
            var    message = new RazorMailMessage("Consolidate/Cancelled", consolidate).Render();
            //IEnumerable<User> users = MembershipService.GetUsersInRole("General Manager", "Manager", "Indent User");
            IEnumerable <User> users = MembershipService.GetAllUserOfEmailTemplate("Consolidate", "Cancelled");

            foreach (User u in users.Where(g => !string.IsNullOrWhiteSpace(g.Email)))
            {
                SendEmail(u.Email, subject, message);
            }
        }
Esempio n. 10
0
        // approve
        // general manager -> manager

        // indent user / manager -> general manager
        private void SendEmail_Consolidate_ReadyForLC(Consolidate consolidate)
        {
            const string subject = "Consolidate confirmed";
            var          message = new RazorMailMessage("Consolidate/Confirmed", consolidate).Render();
            //IEnumerable<User> users = MembershipService.GetUsersInRole("Manager");
            IEnumerable <User> users = MembershipService.GetAllUserOfEmailTemplate("Consolidate", "Confirmed");

            foreach (User u in users.Where(g => !string.IsNullOrWhiteSpace(g.Email)))
            {
                SendEmail(u.Email, subject, message);
            }
        }
        private void SendEmail_ConfirmDocument_Open(ConfirmDocument confirmDoc)
        {
            const string subject = "LC Open";
            var          message = new RazorMailMessage("ConfirmDocument/OpenLC", confirmDoc).Render();
            //IEnumerable<User> users = MembershipService.GetUsersInRole("General Manager");
            IEnumerable <User> users = MembershipService.GetAllUserOfEmailTemplate("ConfirmDocument", "OpenLC");

            foreach (User u in users.Where(f => !string.IsNullOrWhiteSpace(f.Email)))
            {
                SendEmail(u.Email, subject, message);
            }
            User requestUser = MembershipService.GetUser(confirmDoc.RequestUserID);

            SendEmail(requestUser.Email, subject, message);
        }
        private void SendEmail_ConfirmDocument_Updated(ConfirmDocument confirmDoc)
        {
            List <LCStatusRecord> statusRecords = IndentRepository.GetAllConfirmDocumentStatusRecords(confirmDoc.ID).ToList();
            string subject = "LC #" + confirmDoc.ID + " " + (statusRecords.Count() == 1 ? "created" : "updated");

            //IEnumerable<User> users = MembershipService.GetUsersInRole("Finance User");
            IEnumerable <User> users = MembershipService.GetAllUserOfEmailTemplate("ConfirmDocument", "Initial");

            foreach (User u in users.Where(f => !string.IsNullOrWhiteSpace(f.Email)))
            {
                var viewBag = new { User = u, StatusRecords = statusRecords };
                var message = new RazorMailMessage("ConfirmDocument/Initial", confirmDoc, viewBag).Render();
                SendEmail(u.Email, subject, message);
            }
        }
Esempio n. 13
0
        private void SendEmail_IndentUpdate(Indent indent)
        {
            List<IndentStatusRecord> statusRecords = IndentRepository.GetIndentStatusRecords(indent.ID).ToList();

            string subject = "Indent no " + indent.IndentNo + " has been " + (statusRecords.Count() == 1 ? "created" : "updated");

            //IEnumerable<User> users = MembershipService.GetUsersInRole("Indent Manager");
            IEnumerable<User> users = MembershipService.GetAllUserOfEmailTemplate("Indent", "Initial");
            foreach (User u in users.Where(m => m.Email != null))
            {
                var viewBag = new { User = u, StatusRecords = statusRecords };
                var message = new RazorMailMessage("Indent/Initial", indent, viewBag).Render();
                SendEmail(u.Email, subject, message);
            }
        }
Esempio n. 14
0
 public static string RenderMessage(string path, object model = null)
 {
     try
     {
         var mail   = new RazorMailMessage(path, model).Render();
         var stream = mail.AlternateViews[0].ContentStream;
         using (var reader = new StreamReader(stream))
         {
             return(reader.ReadToEnd());
         }
     }
     catch (Exception ex)
     {
         //var a = new ExternalException("template file:" + path + "\n\n" + ex.Message);
         //throw a;
         return("");
     }
 }
Esempio n. 15
0
        // created
        // updated
        // manager -> general manager
        private void SendEmail_ConsolidateUpdated(Consolidate consolidate)
        {
            List <ConsolidateStatusRecord> statusRecords = IndentRepository.GetConsolidateStatusRecords(consolidate.ID).ToList();

            string subject = statusRecords.Count() == 1
                                 ? "New consolidate (id :" + consolidate.ID + ")"
                                 : "Consolidate updated (id: " + consolidate.ID + ")";

            //IEnumerable<User> users = MembershipService.GetUsersInRole("General Manager");
            IEnumerable <User> users = MembershipService.GetAllUserOfEmailTemplate("Consolidate", "Initial");

            foreach (User u in users.Where(g => !string.IsNullOrWhiteSpace(g.Email)))
            {
                var viewBag = new { User = u, StatusRecords = statusRecords };
                var message = new RazorMailMessage("Consolidate/Initial", consolidate, viewBag).Render();
                SendEmail(u.Email, subject, message);
            }
        }
Esempio n. 16
0
        public void EmbeddedResourceTemplate_CanWriteContentToStream()
        {
            var test = new RazorMailMessage("TESTING");

            // Arrange
            var result = string.Empty;
            var stream = new MemoryStream();
            var template = new EmbeddedResourceTemplate(Assembly.GetExecutingAssembly(), "Resources.Test.html");

            // Act
            template.Write(stream);
            stream.Position = 1;
            using (var sr = new StreamReader(stream))
                result = sr.ReadToEnd();

            // Assert
            Assert.That(result, Is.Not.Empty);
        }
Esempio n. 17
0
 protected void SendEmail(string to, string subject, RazorMailMessage message)
 {
     SendEmail("*****@*****.**", to, subject, message);
 }
Esempio n. 18
0
        public void GetMailMessage_CanReturnMailMessage()
        {
            // arrange
            var parser = new Mock<IParser>();
            var message = new RazorMailMessage(ObjectMother.Subject);
            parser.Setup(x => x.BaseUrls(It.IsAny<string>())).Returns<string>(x => x);
            parser.Setup(x => x.StripHtml(It.IsAny<string>())).Returns<string>(x => x);

            // act
            message.To.Add(ObjectMother.To);
            message.Templates.Add("Test template");
            var result = message.GetMailMessage(parser.Object);

            // assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.TypeOf<MailMessage>());
        }
 public MailMessage TestGetMailMessage(RazorMailMessage message)
 {
     return base.GetMailMessage(message);
 }