1

I am trying to group emails sent and received by threads in my Delphi XE2 application. I use Indy 10 components and the idea is to link the email unique Message-IDs with the In-Reply-Tos.

  • First step is to store the Message-ID of the very first email of the thread sent out. This is the email that starts the thread.
  • Second step is to store, for the emails received, the email In-Reply-Tos field. By linking Message-ID and In-Reply-To I can compose the email thread.

The first step is achieved with the following code:

FIdMessage1.MsgId:='Unique ID';
FIdMessage1.ExtraHeaders.Values['Message-Id'] := FIdMessage1.MsgId;

Here the email is sent out with 'Unique ID' in the field Message-ID of the email correctly.

When the recipient of this email replies the In-Reply-Tos is not 'Unique ID' any longer but something like '<-9999999999999999999@unknownmsgid>'. It seems that the recipient email server override my Message-ID.

What can I do in order the server not override my Message-ID ? If my approach is wrong what can I do in order to organize emails sent/received in threads ?

Organizing emails by subject is not an option because there may be different email threads with the same subject.

****UPDATE****

I have solved, temporary, this issue.

I delete the code I mention in the first step above then with this piece of code Get email headers from GMail's "Sent items" folder

This way I can retrieve the email I have just sent and with AMsgList[i].MsgId I can see the email id.

Community
  • 1
  • 1
pio pio
  • 732
  • 1
  • 7
  • 29
  • Every message should have its own unique message-id. You have to look inside the headers after something like `In-Reply-To:` (relation to the replied mail-message-id) or `References:` (relation to all related mail-message-ids) (taken from gmail) – Sir Rufo Jun 15 '14 at 12:01
  • In-Reply-To and References in the header of the email are exactly the same but they don't match with the Message-ID of the first email. This way I cannot link the answer with the first email – pio pio Jun 15 '14 at 12:14
  • No they are not the same. `In-Reply-To` contains only **one** and `References` can contain several message-ids – Sir Rufo Jun 15 '14 at 13:13
  • I meant, in my case they both contain the same id. – pio pio Jun 15 '14 at 14:49

0 Answers0