Comments (9)
The readme has an example. I didn't understand what you are looking for.
from imapnio.
sorry,I didn't understand the readme.md.
I have imap address and account password,how to get the content ?
from imapnio.
how to execute the command ?
Thanks ~
from imapnio.
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.
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.
after I execute fetchCommand
getting the response,
how to convert to MimeMessage
or how to get the subject ?
Thanks~
from imapnio.
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.
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.
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)
- How do I read the messages from the IMAP server. HOT 1
- How find if loginCommand failed due to invalid credentials ? HOT 1
- How many threads in IMAPClient is needed per mailbox ? HOT 1
- IMAPConnectionListener onDisconnect() is not called after timeout HOT 1
- Netty Epoll Bug with lafaspot imapnio client HOT 1
- Maven Could not resolve dependency 2.0.0.0 HOT 5
- API with CompletableFuture/Stage instead of/addition to Future HOT 5
- Performance: imapnio spend most of its time filling stacktraces
- Remove logback core from main dependencies
- ImapAsyncSession: allow to know if the session is open
- STARTTLS support for IMAPClient
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imapnio.