Ejemplo n.º 1
0
        public void SendApplicationEmailToDeveloper(Application application)
        {
            var sysEMail  = PreferenceService.GetTyped <EmailInfo>(Preference.SYSTEM_EMAIL);
            var mail      = PrepareDefaultMail(sysEMail);
            var developer = application.Developer;

            switch (application.State)
            {
            case ApplicationStateEnum.Approved:
                mail.Subject = PreferenceService.Get(Preference.APPLICATION_APPROVED_EMAIL_SUBJECT).Value;
                var confirmationKey = developer.User.ConfirmationKey;
                var url             = string.Format(developerConfirmUrlFormat, PreferenceService.Get(Preference.APPLICATION_URL).Value
                                                    , confirmationKey, application.Id);
                mail.Body = string.Format(PreferenceService.Get(Preference.APPLICATION_APPROVED_EMAIL_BODY).Value,
                                          application.Name, developer.Name, url);
                break;

            case ApplicationStateEnum.Rejected:
                mail.Subject = PreferenceService.Get(Preference.APPLICATION_REJECTED_EMAIL_SUBJECT).Value;
                mail.Body    = string.Format(PreferenceService.Get(Preference.APPLICATION_REJECTED_EMAIL_BODY).Value,
                                             application.Name, developer.DisplayName);
                break;

            default: throw new ChalkableException(ChlkResources.EMAIL_INCORRECT_APP_STATE);
            }
            if (EmailTools.IsValidEmailAddress(developer.Email))
            {
                mail.To.Add(developer.Email);
            }
            SendMail(mail, sysEMail);
        }
Ejemplo n.º 2
0
        private MailMessage PrepareMailToSysadmins(EmailInfo from)
        {
            var sysAdminEmail = ServiceLocator.UserService.GetSysAdmin().Login;
            var mail          = PrepareDefaultMail(from);

            if (EmailTools.IsValidEmailAddress(sysAdminEmail))
            {
                mail.To.Add(sysAdminEmail);
            }
            else
            {
                Trace.TraceWarning(ChlkResources.ERR_EMAIL_INVALID, sysAdminEmail);
            }
            return(mail);
        }
Ejemplo n.º 3
0
        private void SendResettedPassword(string email, string body)
        {
            var fromEmail = PreferenceService.GetTyped <EmailInfo>(Preference.FORGOTPASSWORD_SYSTEM_EMAIL);
            var mail      = PrepareMailToSysadmins(fromEmail);

            if (EmailTools.IsValidEmailAddress(email))
            {
                mail.To.Add(email);
            }
            else
            {
                Trace.TraceWarning(ChlkResources.ERR_EMAIL_INVALID, email);
                return;
            }
            mail.Subject = ChlkResources.EMAIL_CHALKABLE_PASSWORD_RESET;
            mail.Body    = body;
            SendMail(mail, fromEmail);
        }
Ejemplo n.º 4
0
 public void SendChangeEmailToDeveloper(Developer developer, string oldEmail, string newEmail)
 {
     if (!IsAutogenerated(oldEmail))
     {
         var sysEMail   = PreferenceService.GetTyped <EmailInfo>(Preference.SYSTEM_EMAIL);
         var personMail = oldEmail;
         var mail       = PrepareDefaultMail(sysEMail);
         if (EmailTools.IsValidEmailAddress(personMail))
         {
             mail.To.Add(personMail);
         }
         else
         {
             Trace.TraceWarning(ChlkResources.ERR_EMAIL_INVALID, personMail);
             return;
         }
         var bodyTemplate = PreferenceService.Get(Preference.EMAIL_CHANGE_EMAIL_BODY).Value;
         mail.Body = string.Format(bodyTemplate, developer.DisplayName, newEmail);
         SendMail(mail, sysEMail);
     }
 }