문제

I'm writing a mail client using javamail. I followed the example in javamail-samples folder but the CommandInfo is just null for all mails retrieved. As a way of debugging, I wrote the following code:

    Session session = Session.getDefaultInstance(props,null);

    //get store object
    Store store = session.getStore("imaps");

    store.connect("imap.gmail.com", "email", "password");

    System.out.println(store);

    //create folder
    Folder inbox = store.getFolder("INBOX");

    inbox.open(Folder.READ_ONLY);

    Message [] messages = inbox.getMessages();


    for(Message message: messages){            

        //message.
       DataHandler d = message.getDataHandler();

       CommandInfo in = d.getCommand("view");
       System.out.println(in);                
    }

The results:

null
null
null
null
null
null
null
....
....

Anyone have an idea why this is so?

도움이 되었습니까?

해결책

It is finding the simple.mailcap file? Usually it should be in the directory where you run the program. Note that there's only a few viewers included with the program. Are you trying to view a simple plain text message?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top