Open mohaimin95 opened 4 years ago
@mohaimin95 i'm also facing the same issue here. did you find the solution?
Hey @mohaimin95 , I found a approach , Get the thread id by message id. and now you can get all the messages by thread id.
for ex : if you are using Gmail
Folder name
[Gmail]/All Mail
Search criteria
[["HEADER", "MESSAGE-ID", message_id]]
let thread_id = ""
var f = imap.fetch(results, {
bodies: ""
});
f.on("message", async function(msg, seqno) {
msg.on("attributes", function(attrs) {
// Get the thread id from here
thread_id = attrs["x-gm-thrid"]
});
});
f.once("end", function() {
imap.end();
});
Now you got thread id , you can now implement search by thread id
Search criteria
[["X-GM-THRID", thread_id]]
I am trying to get the whole email thread from the inbox using message-id. I have tried using search criteria
var searchCriteria = [['HEADER','IN-REPLY-TO',messageId]];
, But I am getting replies only for the main thread. I want to get whole replies (replies of replies) from the inbox. I have triedvar searchCriteria = [['OR', ['HEADER', 'IN-REPLY-TO', messageId], ['HEADER', 'REFERENCES', messageId]]];
, but none of them helps. Please help me with the need. I have included the whole method below for your reference. Thanks in advance