示例#1
0
        /// <summary>
        /// Connects to email server.
        /// </summary>
        /// <param name="useSSL">if set to <c>true</c> [use SSL].</param>
        /// <returns></returns>
        private bool ConnectToEmailServer(bool useSSL)
        {
            Disconnect();
            if (_client != null && !_client.IsDisposed)
            {
                _client.Dispose();
            }
            _client = new IMAP_Client();
            try {
                if (useSSL)
                {
                    _client.Connect(_settings.Server, WellKnownPorts.IMAP4_SSL, true);          //port 993
                }
                else
                {
                    _client.Connect(_settings.Server, WellKnownPorts.IMAP4, false);             //port 143
                }
                if (_settings.Security == SecurityEnum.TLS)
                {
                    _client.StartTls();
                }

                _client.Login(_settings.User, _settings.Pass);

                return(true);
            } catch (Exception ex) {
                //Debug.WriteLine(ex.Message);
                AppJournal.Write("EmailImapTransport: ConnectToEmailServer " + ex.Message);
                return(false);
            }
        }