What is the difference between these two from java mail perspective? I can see that 2 values are not same for a particular message. So what should I consider an IMAP message's unique id?
If I need to fetch message from an IMAP server corresponding to an unique id, should I use?
MessageIDTerm
or
IMAPFolder.getMessageByUID()
UID is the unique identification number of a email in a IMAP folder. Each mail in a folder is assigned a uid, it is you can say a index maintained by the mail folder. Whereas message-id is a header part of a email.
To understand in a simple term,
UID is a unique number which cannot be duplicated within a folder. If I copy same email twice in a folder, each will have same headers having same message-id but will have a different UID.
Other major difference is,
UID's are assigned by a imap server
MessageId's are set by the email
client.
So it is always better to rely on a UID to extract the email.
Refer : RFC - UID
Related
I'm using JavaMail's IMAP Store.
When opening the inbox, is it safe to assume that the name is always called "INBOX"?
IMAPFolder folder = (IMAPFolder) store.getFolder("INBOX");
Or is the "inbox" name nothing special and on a Swedish IMAP server it could be called "inkorg"?
I guess this same question applies equally to IMAP in general, beyond JavaMail.
Yes. Additionally, according to RFC 3501: INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1, INBOX has a number of special behaviors to boot:
5.1. Mailbox Naming
The case-insensitive mailbox name INBOX is a special name reserved to
mean "the primary mailbox for this user on this server". The
interpretation of all other names is implementation-dependent.
6.3.3. CREATE Command
It is an error to attempt to create INBOX or a mailbox
with a name that refers to an extant mailbox.
6.3.4. DELETE Command
It is an error to attempt to delete INBOX or a
mailbox name that does not exist.
6.3.5. RENAME Command
Renaming INBOX is permitted, and has special behavior. It moves
all messages in INBOX to a new mailbox with the given name,
leaving INBOX empty. If the server implementation supports
inferior hierarchical names of INBOX, these are unaffected by a
rename of INBOX.
Concatenate inbound email messages into a single google document each week and share that document via email. Inbound messages would be filtered into to a specific gmail label as a means of identifying them. A follow-on enhancement would be to lookup the name of the person submitting the request based on the inbound email address in a google contact and add that to the messages concatenated into the google doc.
Is there any way to get the an array of unique id for the messages stored in the in box folder of a mail account through Java language ?
Thanks in Advance.
Depends on exactly what you mean by "unique id".
There's the UIDFolder interface, which provides access to IMAP UIDs. But you need to understand the semantics of IMAP UIDs to understand just how "unique" they are, and aren't.
There's also the Message-ID header that appears on most messages. While it's typically more globally unique than IMAP UIDs, there's no guarantee of uniqueness.
What do you want to do with the unique id once you have it?
We will be sending automated emails through a mail box ,we will send an email with two to three emails in TO column and one or more emails in the CC column ,if i have a wrong email in the TO column in that mail box we will get a delivery report that email is wrong i need to write a program such that it will pick up the wrong email id
Start by reading up on JavaMail FAQ and the com.sun.mail.dsn package. The JavaMail Homepage has all of the downloads you'll need.
You could also enable the mail.smtp.reportsuccess property per the documentation:
When sending a message, detailed information on each address that fails is available in an SMTPAddressFailedException chained off the top level SendFailedException that is thrown. In addition, if the mail.smtp.reportsuccess property is set, an SMTPAddressSucceededException will be included in the list for each address that is successful. Note that this will cause a top level SendFailedException to be thrown even though the send was successful.
We are looking for a way to determine if an email in different users gmail is the same email. For example Person A sends an email to Person B and C who are in the same Google Apps instance.
When retrieving the email with the gmail API the Id and ThreadId are different for the email in both user B and C accounts. Is there some common identifier or is a case of using something like "Sender" + "Recipients" + "Time Sent" as the relating key?
Thanks for your help.
Not sure if/how this is related to Gmail API, but why not use the Message-Id header? (In conjunction with Date header and possibly From if you want to be sure/paranoid. Note that many assumptions may be broken if a mailing-list is part of the delivery to the recipients.)