Exemplo n.º 1
0
 public void DropInstance(MailUser acs)
 {
     this._AccSettings   = null;
     this.popController  = null;
     this.imapController = null;
     this.smtpController = null;
 }
Exemplo n.º 2
0
 public Facade()
 {
     this._accSettings    = AccountSettings.Load(Constants.ACCOUNT_FILE_NAME_SETTINGS);
     this.popController   = new Pop3Controller();
     this._imapController = new ImapController();
     this.smtpController  = new SmtpController();
     this._changeImcoming = false;
 }
Exemplo n.º 3
0
 // connects with default settings
 public static void Connect()
 {
     AccountSettings.AccountInfo ai = Settings.Account.Accounts[0];
     switch (ai.MailAccountType) {
         case AccountType.POP3:
             Pop3 = new Pop3Controller(ai);
             break;
         case AccountType.IMAP:
             Imap4 = new Imap4Controller(ai);
             break;
         default:
             throw new Exception("Invalid value for AccountType");
     }
 }
Exemplo n.º 4
0
    public Facade()
	{
        this._accSettings = AccountSettings.Load(Constants.ACCOUNT_FILE_NAME_SETTINGS);
        this.popController = new Pop3Controller();
        this._imapController = new ImapController();
        this.smtpController = new SmtpController();
        this._changeImcoming = false;
    }
Exemplo n.º 5
0
        /// <summary>
        /// Method for try to connect
        /// </summary>
        /// <returns>The string return.</returns>
        public string TryConnect()
        {
            this.progressBar.Visible = true;
            this.progressBar.Maximum = 10;
            this.progressBar.Value = 0;
            
            this.btnNext.Enabled = false;
            
            this.labelStatus.Text = "Verifying email configuration...";
            
            bool success = true;
            string msg = "You have just successfully completed adding a new account." +
                Environment.NewLine + "Please select finish to save the changes or cancel to discard them.";

            // verify incoming server email configurations.

            try
            {
                if (this._accInfo.MailAccountType == AccountType.POP3)
                {
                    Pop3Controller pop3Controller = new Pop3Controller(this._accInfo);
                    pop3Controller.Disconnect();
                }
                else if (this._accInfo.MailAccountType == AccountType.IMAP)
                {
                    Imap4Controller imap4Controller = new Imap4Controller(this._accInfo);
                    imap4Controller.Disconnect();
                }
            }
            catch (Exception)
            {
                success = false;
                msg = "The incoming server email configuration is not valid.\nPlease make sure that you have a stable internet connection,\nand have entered the correct username and password.";
            }

            // verify outcoming server email configurations.

            if (success)
            {
                this.labelStatus.Text = "Sending test email...";

                try
                {
                    SmtpController smtpController = new SmtpController();
                    ActiveUp.Net.Mail.Message message = smtpController.SendMessage(this._accInfo,
                                                                                   this._accInfo.EmailAddress, "XMail", "Test XMail email. If you can read this, XMail was set up correctly!", new string[0]);
                }
                catch (Exception)
                {
                    success = false;
                    msg = "The outgoing server email configuration is not valid.\nPlease make sure that you have a stable internet connection,\nand have entered the correct information.";
                }
            }
            
            
            if (success)
            {
                labelStatus.Text = msg;
                this.btnNext.Enabled = true;
                btnBack.Enabled = false;
                btnNext.Text = "Finish";
                _close = true;
                btnNext.Click -= btnNext_Click;
                btnNext.Click += delegate { this.Close(); };
            }
            else
            {
                this.labelStatus.Text = msg;
            }
            
            this.progressBar.Value = 10;
            this.progressBar.Visible = false;
            
            return string.Empty;
        }