Esempio n. 1
0
        /*
         * returns message count from pop3 server
         */
        internal static int GetMessageCount(Core.Node ip, Core.Node dp)
        {
            string host        = Expressions.GetExpressionValue <string>(ip.GetValue("host", ""), dp, ip, false);
            int    port        = Expressions.GetExpressionValue <int>(ip.GetValue("port", "-1"), dp, ip, false);
            bool   implicitSsl = Expressions.GetExpressionValue <bool>(ip.GetValue("ssl", "false"), dp, ip, false);
            string username    = Expressions.GetExpressionValue <string>(ip.GetValue("username", ""), dp, ip, false);
            string password    = Expressions.GetExpressionValue <string>(ip.GetValue("password", ""), dp, ip, false);

            using (Pop3Client client = new Pop3Client())
            {
                client.Connect(host, port, implicitSsl);
                client.AuthenticationMechanisms.Remove("XOAUTH2");
                if (!string.IsNullOrEmpty(username))
                {
                    client.Authenticate(username, password);
                }
                int retVal = client.GetMessageCount();
                client.Disconnect(true);
                return(retVal);
            }
        }