Esempio n. 1
0
 void AddReceipients(EmailRule emailRule, IModelApplicationEmail modelApplicationEmail, EmailTemplateEngine.Email email, object o) {
     var emailReceipientGroup =modelApplicationEmail.Email.EmailReceipients.First(
             @group => @group.GetValue<string>("Id") == emailRule.EmailReceipientsContext);
     foreach (var modelEmailReceipient in emailReceipientGroup) {
         var criteriaOperator = GetCriteriaOperator(modelEmailReceipient,o);
         var objects = ObjectSpace.GetObjects(modelEmailReceipient.EmailReceipient.TypeInfo.Type,                                                     criteriaOperator);
         var sendToCollection = GetSendToCollection(email, modelEmailReceipient);
         foreach (var obj in objects) {
             var item = modelEmailReceipient.EmailMember.MemberInfo.GetValue(obj) as string;
             sendToCollection.Add(item);
         }
     }
 }
 EmailTemplateEngine.Email CreateEmail(EmailTemplateEngine.EmailTemplateEngine templateEngine, LogicRuleInfo logicRuleInfo, EmailRule emailRule, IModelSmtpClientContext modelSmtpClientContext, IEmailTemplate emailTemplateObject, IModelApplicationEmail modelApplicationEmail) {
     var email = templateEngine.Execute(logicRuleInfo.Object, emailRule.ID);
     if (emailRule.CurrentObjectEmailMember != null) {
         var toEmail = emailRule.CurrentObjectEmailMember.MemberInfo.GetValue(logicRuleInfo.Object) as string;
         email.To.Add(toEmail);
     }
     if (!string.IsNullOrEmpty(emailRule.EmailReceipientsContext)) {
         AddReceipients(emailRule, modelApplicationEmail, email,logicRuleInfo.Object);
     }
     email.From = modelSmtpClientContext.SenderEmail;
     email.Subject = emailTemplateObject.Subject;
     modelSmtpClientContext.ReplyToEmails.Split(';').Each(s => email.ReplyTo.Add(s));
     return email.To.Count == 0 ? null : email;
 }
Esempio n. 3
0
        public static void Main() {
            IEmailTemplateContentReader templateReader = new FileSystemEmailTemplateContentReader();
            IEmailTemplateEngine templateEngine = new EmailTemplateEngine(templateReader);

            IEmailSender sender = new EmailSender {
                CreateClientFactory = () => new SmtpClientWrapper(CreateSmtpClientWhichDropsInLocalFileSystem())
            };

            var subsystem = new EmailSubsystem("*****@*****.**", templateEngine, sender);

            subsystem.SendWelcomeMail("Jon Smith", "~!Agc2d#7", "*****@*****.**");

            Console.WriteLine("Mail delivered, check the outbox folder.");
            Console.Read();
        }
Esempio n. 4
0
        public static void Main()
        {
            IEmailTemplateContentReader templateReader = new FileSystemEmailTemplateContentReader();
            IEmailTemplateEngine        templateEngine = new EmailTemplateEngine(templateReader);

            IEmailSender sender = new EmailSender {
                CreateClientFactory = () => new SmtpClientWrapper(CreateSmtpClientWhichDropsInLocalFileSystem())
            };

            var subsystem = new EmailSubsystem("*****@*****.**", templateEngine, sender);

            subsystem.SendWelcomeMail("Jon Smith", "~!Agc2d#7", "*****@*****.**");

            Console.WriteLine("Mail delivered, check the outbox folder.");
            Console.Read();
        }
Esempio n. 5
0
 static ICollection<string> GetSendToCollection(EmailTemplateEngine.Email email, IModelEmailReceipient modelEmailReceipient) {
     var collection = email.To;
     if (modelEmailReceipient.EmailType != EmailType.Normal)
         collection = modelEmailReceipient.EmailType == EmailType.BCC ? email.Bcc : email.CC;
     return collection;
 }