Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用selenium(Java)阅读outlook office 365电子邮件_Java_Selenium_Selenium Webdriver_Outlook_Office365 - Fatal编程技术网

使用selenium(Java)阅读outlook office 365电子邮件

使用selenium(Java)阅读outlook office 365电子邮件,java,selenium,selenium-webdriver,outlook,office365,Java,Selenium,Selenium Webdriver,Outlook,Office365,在使用Selenium Java执行Web base测试期间,我需要阅读来自客户端outlook office 365的电子邮件。以前,该代码在主机:mail.client.co.in(Outlook 2010/2016)上运行良好。以前,代码用于从我的outlook中读取电子邮件,而无需打开任何web OWA。现在我的电子邮件迁移到outlook.Office365.com,因此下面的代码失败。我正在使用pop3协议阅读电子邮件 最终目标是阅读电子邮件,并且需要设置使用SeleniumJava

在使用Selenium Java执行Web base测试期间,我需要阅读来自客户端outlook office 365的电子邮件。以前,该代码在主机:mail.client.co.in(Outlook 2010/2016)上运行良好。以前,代码用于从我的outlook中读取电子邮件,而无需打开任何web OWA。现在我的电子邮件迁移到outlook.Office365.com,因此下面的代码失败。我正在使用pop3协议阅读电子邮件

最终目标是阅读电子邮件,并且需要设置使用SeleniumJava阅读电子邮件的属性

下面是我正在使用的Selenium脚本:

System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
        String host = "outlook.office365.com";// change accordingly
        @SuppressWarnings("unused")
        String mailStoreType = "pop3";
        String username = " client username";
        String password = "********";

        try {
            // create properties field
            Properties properties = new Properties();
            properties.put("mail.store.protocol", "pop3");
            properties.put("mail.pop3.host", host);
            properties.put("mail.pop3.port", "995");
            properties.put("mail.pop3.starttls.enable","true");

            Session emailSession = Session.getDefaultInstance(properties);
            emailSession.setDebug(true);

            // create the POP3 store object and connect with the pop server
            Store store = emailSession.getStore("pop3s");

            store.connect(host, username, password);

            // create the folder object and open it
            Folder emailFolder = store.getFolder("INBOX");
            emailFolder.open(Folder.READ_ONLY);

            // retrieve the messages from the folder in an array and print it
            Message[] messages = emailFolder.getMessages();
            // System.out.println("messages.length---" + messages.length);
            for (int i = messages.length - 1; i == messages.length - 1; i--) {
                Message message = messages[i];
                // System.out.println(message.getSubject());
                String rvnmail = getTextFromMessage(message);
控制台错误:

DEBUG: setDebug: JavaMail version 1.6.2
DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle]
DEBUG POP3: mail.pop3s.rsetbeforequit: false
DEBUG POP3: mail.pop3s.disabletop: false
DEBUG POP3: mail.pop3s.forgettopheaders: false
DEBUG POP3: mail.pop3s.cachewriteto: false
DEBUG POP3: mail.pop3s.filecache.enable: false
DEBUG POP3: mail.pop3s.keepmessagecontent: false
DEBUG POP3: mail.pop3s.starttls.enable: false
DEBUG POP3: mail.pop3s.starttls.required: false
DEBUG POP3: mail.pop3s.finalizecleanclose: false
DEBUG POP3: mail.pop3s.apop.enable: false
DEBUG POP3: mail.pop3s.disablecapa: false
DEBUG POP3: connecting to host "outlook.office365.com", port 995, isSSL true
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: outlook.office365.com, 995; timeout -1;
嵌套异常为:java.net.ConnectException:Connection超时:connect com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:217) 在javax.mail.Service.connect(Service.java:366)
在javax.mail.Service.connect(Service.java:246)

您能确定这不是网络问题吗?能否使用其他工具连接到outlook.office365.com:995?例如,
telnet outlook.office365.com 995
telnet不工作。错误:连接到outlook.office365.com…无法在端口995上打开与主机的连接:连接失败。我正在我的客户机虚拟机上工作,并使用OutlookOffice365,以前的脚本工作得非常好。代码中唯一的技术是主机:mail.client.co.*。我试图将主机名更改为outlook.office365.com;但是,它不起作用。请将您的虚拟机配置为允许我尝试连接的客户端访问端口。如何配置?目前,由于我刚刚开始我的职业生涯,我希望您能帮助我提供详细的解决方案。我希望你不介意。我还想知道outlook.office365.com是基于云计算的,不能从虚拟机访问telnet。如果你能帮助我采取进一步的步骤或指导,我会更高兴。