Ejemplo n.º 1
0
        /// <summary>
        /// Connects to the server.
        /// </summary>
        /// <returns>True for successful connection. False otherwise.</returns>
        private async Task <bool> ConnectAsync()
        {
            try
            {
                if (IsConnected)
                {
                    Socket.Dispose();
                    IsConnected = false;
                }

                Socket = new SmtpSocket(Server, Port, SSL);

                SmtpResponse response = await Socket.EstablishConnection();

                if (response.ContainsStatus(SmtpCode.ServiceReady))
                {
                    IsConnected = true;

                    return(true);
                }
            }
            catch
            {
                return(false);
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Connects to the server.
        /// </summary>
        /// <returns>True for successful connection. False otherwise.</returns>
        public async Task <bool> Connect()
        {
            try
            {
                if (IsConnected)
                {
                    Socket.Close();
                    IsConnected = false;
                }

                Socket = new SmtpSocket(Server, Port, SSL, Username, Password);

                SmtpResponse response = await Socket.EstablishConnection();

                if (response.Contains(SmtpCode.ServiceReady))
                {
                    IsConnected = true;

                    return(true);
                }
            }
            catch
            {
                return(false);
            }

            return(false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Connects to the server.
        /// </summary>
        /// <returns>True for successful connection. False otherwise.</returns>
        public async Task<bool> Connect()
        {
            try
            {
                if (IsConnected)
                {
                    Socket.Close();
                    IsConnected = false;
                }

                Socket = new SmtpSocket(Server, Port, SSL, Username, Password);

                SmtpResponse response = await Socket.EstablishConnection();

                if (response.Contains(SmtpCode.ServiceReady))
                {
                    IsConnected = true;

                    return true;
                }
            }
            catch
            {
                return false;
            }

            return false;
        }