i have try this val f = store.defaultFolder.list("*")
but just get :
INBOX,
Sent Messages,
Drafts,
Deleted Messages,
Junk,
how to access QQMail or other Mail "Starred" folder
"starred" is not a folder is a flag , and i get it by this line code message.flags.systemFlags.contains(Flags.Flag.FLAGGED)
if get true means this message belong to "starred folder"
Related
I have searched and searched and cannot seem to pull data from the draft's folder within the device. Basically I am wanting to pull the typed (unsent) message from the user's conversation, my thinking is that it was stored within Android as a draft. However if I try to search the draft folder using the uri-
Uri message = Uri.parse("content://sms/draft/");
No data is returned. I have adjusted it to remove the 'draft' portion and it does return all my inbox messages. I have ensured that the permissions have been set and accepted.
I am using Paho client for java to connect to activeMq over mqtt. I noticed one strange thing. There are several folder created having names like "paho101658642587966-tcp1270011883" and having empty .lck files. Why are these used and when are they created.
These files are created to store inflight messages for QOS2 message before their delivery to the broker can be confirmed.
They are created by the MQTTDefaultFilePersistence class, you can change the directory name and path by creating your own MQTTDefaultFilePresistence object and passing it to the MQTTClient constructor.
You can also switch to a in memory store, but this will change how QOS2 messages are handled if the client crashes before a delivery can be confirmed.
You can specify the /tmp directory for client execution as:
String receiverId = UUID.randomUUID().toString();
IMqttClient receiver = new MqttClient(
"tcp://" + properties.getProperty("host") + ":" + properties.getProperty("port"), receiverId, new MqttDefaultFilePersistence("/tmp"));
I have already seen another similar posts but it is still not working. I am using javax.email with Gmail and I can read messages successfully , but when I want to delete them, it does not do anything... I am doing this:
// Open folder
this.folder = this.store.getFolder("Inbox");
this.folder.open(Folder.READ_WRITE);
// Get messages with specified filters
messages = this.folder.search(messagesFilters);
// Delete
message[0].setFlag(Flag.DELETED,true);
// Close
this.folder.expunge();
this.folder.close(true);
this.store.close();
But nothing happens in Gmail. Do you know how to do it?
My application is checking the patterns of the subjects of the mails on the Inbox server folder and if some pattern is found, we should move the email (com.sun.mail.imap.IMAPMessage) to another folder - called 'test' for example (copy will do the job also).
I searched on the Internet for the solution but I could not find anything helpful.
Can you tell me how can I move / copy IMAPMessage from inbox to another folder on server?
Thank you
Presumably you're already using a com.sun.mail.imap.IMAPFolder?
That class has the method addMessages(Message[] msgs). Use it to add a Message to the new folder.
Alternatively, as mentioned by #gospodin, there's a copyMessages(Message[] msgs, Folder destinationFolder) method, which provides a shortcut for copying messages from their original folder to a new one.
It is a bad idea to move a message with methods like copyMessages(), addMessages() or appendMessage() and removing the old message, because these methods generates a new message. The new message have an different Message-ID in the header. If you response on the new message, the receiver cannot relate the response to his sent mail, because he does not know the new Message-ID. You have to cast the folder to a IMAPFolder. IMAPFolder has the method moveMessages(Message[] msgs, Folder targetFolder) to move messages without tampering the header Message-ID.
List<Message> tempList = new ArrayList<>();
tempList.add(myImapMsg);
Message[] tempMessageArray = tempList.toArray(new Message[tempList.size()]);
fromFolder.copyMessages(tempMessageArray, destFolder);
I have a java program that acts as a POP3 client using javax.mail. I am able to list and retrieve the contents of a Gmail inbox no problem. However, I cannot seem to delete emails. Here is the (important parts of the) code:
POP3Store sto=... another method creates and connects the POP3Store
Folder ibx=sto.getFolder("INBOX");
ibx.open(Folder.READ_WRITE);
Message[] msgarr=ibx.getMessages();
for(int mi=0; mi<msgarr.length; mi++) {
...do stuff with the message
msgarr[mi].setFlag(Flags.Flag.DELETED, true);
}
ibx.close(true); //folder.close(true) indicates to expunge the folder
sto.close();
After running this and seeing it handle each message, I go into Gmail and the emails are still there, and even showing as unread. If I re-run the java client, it will see and handle the same emails.
This same code happily deletes emails from an exchange server.
How can I get Gmail to delete emails?
Gmail handles POP deletion specially.
You can configure what Gmail should do when a message is deleted through POP in Gmail Settings, on the Forwarding and POP / IMAP tab.
As SLaks says, Gmail is a special case where it has its own settings for controlling deletion that override whatever the client wants to do.
It can be edited in the Forwarding and POP / IMAP
However, I want to add that for a message to be considered "downloaded" by Gmail, you need to have retrieved the content of each message, and in the case of multipart message types, the content of each part within that message.
Here's some example code that I use to force the deletion of unwanted messages from Gmail:
// Grab the content to get the email off the server
// folder is of type javax.mail.Folder and is already in the correct state to get messages from the mail store (Gmail)
Message msg = folder.getMessage(1);
Multipart multipart = (Multipart) msg.getContent();
int partcount = multipart.getCount();
for (int count = 0; count < partcount; count++) {
multipart.getBodyPart(count);
}
If you prepend "recent:" in your pop3 username you will solve.
Example: recent:yourusername#gmail.com
This connects to gmail using Recent Mode