Code Monkey home page Code Monkey logo

Comments (9)

nvsnvikram avatar nvsnvikram commented on September 16, 2024

The readme has an example. I didn't understand what you are looking for.

from imapnio.

cxc222 avatar cxc222 commented on September 16, 2024

sorry,I didn't understand the readme.md.
I have imap address and account password,how to get the content ?

from imapnio.

cxc222 avatar cxc222 commented on September 16, 2024

how to execute the command ?
Thanks ~

from imapnio.

fansu avatar fansu commented on September 16, 2024

First, read this RFC3501 to know how each IMAP protocol works and how each command is used. https://datatracker.ietf.org/doc/html/rfc3501

Second, as explained in readme, following example command can be used to fetch CAPABILITY for example. For FETCH command the UidFetchCommand is one example to use.

final Future<ImapAsyncResponse> capaCmdFuture = session.execute(new CapaCommand());

from imapnio.

cxc222 avatar cxc222 commented on September 16, 2024

First, read this RFC3501 to know how each IMAP protocol works and how each command is used. https://datatracker.ietf.org/doc/html/rfc3501

Second, as explained in readme, following example command can be used to fetch CAPABILITY for example. For FETCH command the UidFetchCommand is one example to use.

final Future<ImapAsyncResponse> capaCmdFuture = session.execute(new CapaCommand());

thanks, I see ~

from imapnio.

cxc222 avatar cxc222 commented on September 16, 2024

after I execute fetchCommand getting the response,
how to convert to MimeMessage or how to get the subject ?

Thanks~

from imapnio.

fansu avatar fansu commented on September 16, 2024

Following is just an example, values need to be adjusted.
Learn something about how com.sun.mail.imap.protocol.FetchResponse works, it will be helpful.

final Future<ImapAsyncResponse> cmdFuture = session.execute(new UidFetchCommand(....));
final ImapAsyncResponse resp = cmdFuture.get(30 * 1000, TimeUnit.MILLISECONDS);
final IMAPResponse[] imapResp = resp.getResponseLines().toArray(new IMAPResponse[0]);

final int len = imapResp.length;
for (int i = 0; i < len; i++) {
    IMAPResponse response = imapResp[i];
    if (response.keyEquals("FETCH")) {
        final FetchResponse r = new FetchResponse(response, new FetchItem[0]);
        // Now you get FetchResponse, and you can do operation with it, notes following import is needed
        //    com.sun.mail.imap.protocol.FetchResponse
        //   com.sun.mail.imap.protocol.IMAPResponse
        final BODY body = r.getItem(BODY.class);
        InternetHeaders headers = new InternetHeaders(body.getByteArrayInputStream());
        String subject = headers.getHeader("Subject")[0]; // now you are able to get subject
    }
}

from imapnio.

cxc222 avatar cxc222 commented on September 16, 2024

Following is just an example, values need to be adjusted. Learn something about how com.sun.mail.imap.protocol.FetchResponse works, it will be helpful.

final Future<ImapAsyncResponse> cmdFuture = session.execute(new UidFetchCommand(....));
final ImapAsyncResponse resp = cmdFuture.get(30 * 1000, TimeUnit.MILLISECONDS);
final IMAPResponse[] imapResp = resp.getResponseLines().toArray(new IMAPResponse[0]);

final int len = imapResp.length;
for (int i = 0; i < len; i++) {
    IMAPResponse response = imapResp[i];
    if (response.keyEquals("FETCH")) {
        final FetchResponse r = new FetchResponse(response, new FetchItem[0]);
        // Now you get FetchResponse, and you can do operation with it, notes following import is needed
        //    com.sun.mail.imap.protocol.FetchResponse
        //   com.sun.mail.imap.protocol.IMAPResponse
        final BODY body = r.getItem(BODY.class);
        InternetHeaders headers = new InternetHeaders(body.getByteArrayInputStream());
        String subject = headers.getHeader("Subject")[0]; // now you are able to get subject
    }
}

Thanks, I see ~

from imapnio.

nvsnvikram avatar nvsnvikram commented on September 16, 2024

This library is for accessing messages through IMAP server and client using mime libraries like apache or sun to read the message content. Reading mime message content is outside of this library.

from imapnio.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.