Пример #1
0
        private static MailBox CreateAccountSimple(string email, string password)
        {
            var begin_date = DateTime.Now.Subtract(new TimeSpan(MailBox.DefaultMailLimitedTimeDelta));

            var mail_box_manager = new MailBoxManager(30);
            try
            {
                Logger.Info("Search mailbox settings:");
                var mbox = mail_box_manager.SearchMailboxSettings(email, password, "", 0);

                Logger.Info("Account: " + mbox.Account + "; Password: "******"Imap: " + mbox.Imap + "; Server: " + mbox.Server + "; Port: " + mbox.Port +
                            "; AuthenticationType: " + mbox.AuthenticationTypeIn + "; EncryptionType: " + mbox.IncomingEncryptionType);
                Logger.Info("SmtpServer: " + mbox.SmtpServer + "; SmtpPort: " + mbox.SmtpPort + "; AuthenticationType: " 
                    + mbox.AuthenticationTypeSmtp + "; OutcomingEncryptionType: " + mbox.OutcomingEncryptionType);

                mbox.BeginDate = begin_date; // Apply restrict for download

                MailServerHelper.Test(mbox);

                return mbox;
            }
            catch (ImapConnectionException ex_imap)
            {
                if (ex_imap is ImapConnectionTimeoutException)
                    Logger.Info("ImapConnectionTimeoutException: " + ex_imap.Message);
                else Logger.Info("ImapConnectionException: " + ex_imap.Message);
            }
            catch (Pop3ConnectionException ex_pop)
            {
                if (ex_pop is Pop3ConnectionTimeoutException)
                    Logger.Info("Pop3ConnectionTimeoutException: " + ex_pop.Message);
                else Logger.Info("Pop3ConnectionException: " + ex_pop.Message);
            }
            catch (SmtpConnectionException ex_smtp)
            {
                if (ex_smtp is SmtpConnectionTimeoutException)
                    Logger.Info("SmtpConnectionTimeoutException: " + ex_smtp.Message);
                else Logger.Info("SmtpConnectionException: " + ex_smtp.Message);
            }
            catch (Exception ex)
            {
                Logger.Info("Exception: " + ex.Message);
            }
            throw new Exception();
        }