Reputation: 2188
I have a very special requirement
I am using Java Mail API to access a user's Inbox. You can say its like a service inbox for complaints. User registers a complaint by sending an email to this address. I fetch every email from Inbox and create a new complaint. My problem is that I don't want to create unnecessary complaints for reply or forwarded emails. Is there a way to find out that.
Upvotes: 4
Views: 5861
Reputation: 123608
Reading the email header might help, see http://javamail.kenai.com/nonav/javadocs/javax/mail/Part.html#getAllHeaders(). In case of replies, the message header would include:
In-Reply-To: Message-ID of the message that this is a reply to
In case of a forwarded message, selected headers might be preserved. Not as straight-forward as the previous case, but it might still be possible to determine if it was a forwarded message. Refer to http://en.wikipedia.org/wiki/Email_forwarding#Manual_client-based_forwarding for details.
Upvotes: 2
Reputation: 9705
Most email clients add Re:
or Fwd:
to the subject line, but I wouldn't rely on that to determine whether an email is a reply or forwarded text; for example, a German mailclient might put Betr.:
in front of the original subject.
Instead, you might want to look at the In-Reply-To:
header and/or the References:
header. See RFC 4021 for detailed information on those headers.
You can retrieve the headers from a Message
by calling the getHeader(java.lang.String)
method.
Upvotes: 4