예제 #1
0
        public AccountManager()
        {
            InitializeComponent();
            this.Title = CIV.strings.AccountManager_Title;
            this.DataContext = this;

            _settings = ProgramSettings.Load();

            RefreshInternetAccess();

            ClientList = new ObservableCollection<CIVAccount>();

            // Chargement de la liste des modèles de courriel
            MailTemplateList = new ObservableCollection<string>();

            MailFactory mailFactory = new MailFactory();
            for (int i = 0; i < mailFactory.MailTemplates.Count; i++)
                MailTemplateList.Add(mailFactory.MailTemplates[i].Name);

            foreach (CIVAccount account in _settings.Accounts)
                ClientList.Add(account);

            InitializeBinding(txtUsername, txtUsername.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled");
            InitializeBinding(txtQuotaQuantity, txtQuotaQuantity.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled");
            InitializeBinding(txtMailRecipients, txtMailRecipients.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled");

            chkSendMail.IsEnabled = _settings.EmailSMTP.Active;
        }
예제 #2
0
        /// <summary>
        /// Envoi un courriel
        /// </summary>
        private void SendMail()
        {
            if (ProgramSettings.Instance.EmailSMTP.Active &&
                        Account.SendMail &&
                        !String.IsNullOrEmpty(Account.MailRecipients) &&
                        !String.IsNullOrEmpty(Account.MailSubject) &&
                        !String.IsNullOrEmpty(Account.MailTemplate))
            //if (true)
            {
                // Validation que toutes les informations sont disponible pour l'envoi (faille de la v3.0.1)
                try
                {
                    SetMessage(CIV.strings.ClientDashboard_MailSending, String.Empty, ScreenMessageType.Normal);

                    MailFactory mailFactory = new MailFactory();
                    mailFactory.SendMailHTML(new MailTagFormater(Account.Account),
                                             ProgramSettings.Instance.EmailSMTP,
                                             Account.MailRecipients,
                                             Account.MailSubject,
                                             Account.MailTemplate,
                                             Account.Account);
                    SetMessage(CIV.strings.ClientDashboard_MailSended, Account.MailRecipients, ScreenMessageType.Normal);
                }
                catch (SmtpException smtpException)
                {
                    // Ne pas logguer les erreurs smtp
                    SetMessage(smtpException);
                }
                catch (Exception mailException)
                {
                    LogEngine.Instance.Add(new LogElementBO() { Error = new CivException(mailException) }, ProgramSettings.Instance.AutomaticSendReport);
                    SetMessage(mailException);
                }
            }
        }