The References header is set when you reply to a message. If the message you're reading is not a reply, it's not likely to have a References header. And even for replies it depends on the mailer that sent the reply to add the header; some don't. You always have to be prepared for the header to be missing.
How do I get email references in Yahoo mail?
-
26-06-2022 - |
Question
I have the following code that gets inbox from YahooMail :-
this._store = _session.getStore("imaps");
this._store.connect("imap.mail.yahoo.com", 993, this._uid, this._pwd);
Folder inbox = this._store.getFolder("Inbox");
SearchTerm unread = new FlagTerm(new Flags(Flag.SEEN), false);
IMAPMessage[] msgs = (IMAPMessage[]) inbox.search(unread);
This returned me unread messages in the form of variable msg. I earlier had this line of code that worked fine with gmail :-
String ref = msg.getHeader("References")[0];
But now with Yahoo, this gives me Null Pointer Exception.
Now the Question is, are references not stored in the message header, in YahooMail, unlike Gmail ?
Solution
OTHER TIPS
The References are set in Yahoo mail, just like Gmail and other Email Providers Email.
See this doc for more information : http://cr.yp.to/immhf/thread.html
The Problem like Bill Shannon mentioned is that for the very first message, with no previous replied to mail. The References are empty. So the following code gives errors :
String ref = msg.getHeader("References")[0];
This only requires Exception handling, and the rest of it works just fine.