JDAVMail是一个开源的访问WebDav邮箱的服务,可以访问Hotmail, 我使用之后总是有错误,请教大侠解答
源码:
public static void main(String[] args) {
try {
                        Properties prop = new Properties();
                        // Set the default enveloppe sender address
                        prop.setProperty("mail.davmail.from", "[email protected]");
                        Session ses = Session.getInstance(prop);                        // Create the transport connection
                        Transport transport = ses.getTransport("davmail_xmit");
                        transport.connect(null, "xx", "***");                        // Prepare the message
                        MimeMessage txMsg = new MimeMessage(ses);
                        txMsg.setSubject("Test subject");                        InternetAddress addrFrom = new InternetAddress("[email protected]");
                        txMsg.setFrom(addrFrom);                        InternetAddress addrTo = new InternetAddress("[email protected]", "zhh");
                        txMsg.addRecipient(Message.RecipientType.TO, addrTo);                        txMsg.setText("Hello world !");
                        txMsg.setSentDate(new Date());                        // Send the message
                        transport.sendMessage(txMsg, txMsg.getAllRecipients());
                } catch (Exception ex) {
                        ex.printStackTrace();
                }
        }出现错误如下:
javax.mail.NoSuchProviderException: No provider for davmail_xmit at javax.mail.Session.getProvider(Session.java:289) at javax.mail.Session.getTransport(Session.java:483) at javax.mail.Session.getTransport(Session.java:464) at com.posisoft.jdavmail.TestReceive.main(TestReceive.java:28)

解决方案 »

  1.   

    Session ses = Session.getInstance(prop,null);
    把下面的null改成你要连接的服务器地址。
    transport.connect(null, "xx", "***");
      

  2.   

    请问btb368,如何用程序作Hotmail的客户端,来接收邮件
      

  3.   

    public static void main(String[] args) {
                    try {
                            Properties prop = new Properties();
                            //Properties prop = new Properties();
                            Session ses = Session.getInstance(prop);
                            //使用JDAVMail Provider
                            Store store = ses.getStore("davmail");                        store.connect(null, "[email protected]", "aa");
                            if (store.isConnected()) {
                                    Folder inbox = store.getFolder("INBOX");
                                    if (inbox.exists()) {
                                            inbox.open(Folder.READ_ONLY);
                                            int nCount = inbox.getMessageCount();
                                            System.out.println("Inbox contains " + nCount + " messages");                                        // Get the last message in the Inbox
                                            MimeMessage msg = (MimeMessage)inbox.getMessage(nCount);
                                            System.out.println("Subject : " + msg.getSubject());
                                            System.out.println("From : " + msg.getFrom()[0].toString());
                                            System.out.println("Content type : " + msg.getContentType());                                        System.out.println(msg.getContent());
                                    }
                            }
                    } catch (Exception ex) {
                            ex.printStackTrace();
                    }
            }这是我从事例考得邮件接收程序,出现错误如下:
    2006-5-11 19:33:43 org.apache.commons.httpclient.HttpMethodBase processResponseHeaders警告: Cookie rejected: "HMSatchmo=0". Illegal domain attribute ".hotmail.com". Domain of origin: "services.msn.com"2006-5-11 19:33:43 org.apache.commons.httpclient.HttpMethodBase processResponseHeaders警告: Cookie rejected: "HMMS2954=7CECB06078A50CDE4E3E4A6574ED25F4D8CB8FC046100166C8FED10394956D90". Illegal domain attribute ".hotmail.com". Domain of origin: "services.msn.com"2006-5-11 19:33:43 org.apache.commons.httpclient.HttpMethodBase processRedirectResponse信息: Redirect requested but followRedirects is disabled2006-5-11 19:33:44 org.apache.commons.httpclient.HttpMethodBase processRedirectResponse信息: Redirect requested but followRedirects is disabled2006-5-11 19:33:45 org.apache.commons.httpclient.HttpMethodBase processRedirectResponse信息: Redirect requested but followRedirects is disabled
      

  4.   

    现在hotmail不允许通过outlook访问了,请问有哪位做过hotmail的客户端