I'm going to develop a ticketing system with c# that should send an email containing the ticket content to the receiver upon ticket submission and the receiver should be able to reply to that email which results in sender receiving the email of the reply. What puzzles me is that how am I going to keep track of that specific ticket which being replied by the receiver. I'm not looking for any code, just concepts or best practices.
3 Answers
Theoretically, you might use the Message-ID
in conjunction with In-Reply-To
, as described in the RFC 5322:
The "Message-ID:" field provides a unique message identifier that refers to a particular version of a particular message. The uniqueness of the message identifier is guaranteed by the host that generates it (see below). This message identifier is intended to be machine readable and not necessarily meaningful to humans. A message identifier pertains to exactly one version of a particular message; subsequent revisions to the message each receive new message identifiers.
The "In-Reply-To:" and "References:" fields are used when creating a reply to a message. They hold the message identifier of the original message and the message identifiers of other messages (for example, in the case of a reply to a message that was itself a reply). The "In-Reply-To:" field may be used to identify the message (or messages) to which the new message is a reply, while the "References:" field may be used to identify a "thread" of conversation.
When creating a reply to a message, the "In-Reply-To:" and "References:" fields of the resultant message are constructed as follows:
The "In-Reply-To:" field will contain the contents of the "Message-ID:" field of the message to which this one is a reply (the "parent message"). If there is more than one parent message, then the "In-Reply-To:" field will contain the contents of all of the parents' "Message-ID:" fields. If there is no "Message-ID:" field in any of the parent messages, then the new message will have no "In-Reply-To:" field.
Of course, you should keep tracking of mappings between the Message-ID
field and you internal ticket number in a separate database table.
Example
A new email E1 is sent from yourCompany.com.
A reply R1 is received from yahoo.com. The message header information:
References: <11111@yourCompany.com> Message-ID: <22222@webServer.yahoo.com> In-Reply-To: <11111@yourCompany.com>
A reply R2 to R1 is sent from yourCompany.com.
A reply R3 to R2 is received from yahoo.com. The message header information:
References: <11111@yourCompany.com> <22222@webServer.yahoo.com> <33333@yourCompany.com> Message-ID: <44444@webServer.yahoo.com> In-Reply-To: <33333@yourCompany.com>

- 1
- 1

- 31,789
- 6
- 54
- 78
-
Usually, a reason for the down-vote is constructive. – Alex Filipovici Oct 29 '13 at 09:33
-
1Hey Alex I did not down-vote you, I did up vote you and your solution makes sense. thanks a bunch :) – arash moeen Nov 20 '13 at 06:46
-
Alex what I can't figure out is that when my ticket is created with the first message, the email will be sent, I've tried adding a X-tkt-Id as my custom header but as it seems custom headers will be ignored by most of the servers and as funny as it might sound the mail server I'm using doesn't store those sent emails in the sent box. So basically I can't get my hands of the first email's message-id... probably I'm missing something here. can you help please? thanks – arash moeen Nov 20 '13 at 09:21
-
Thanks again Alex for your answer, although I was thinking about the same thing, your answer cleared things up for me, although I have to find a way to get my hands on that very first email using it's message id because for some reason this mail server doesn't store emails sent via my application. – arash moeen Nov 24 '13 at 06:25
I think the only way to do this (and I never saw a ticketing-system who does that differently) is adding the ID into the subject-line.
In our case, we have subject-headers like "bla bla bla <<< CALLID: 12312 >>>". With regex, that's quite easy to catch

- 741
- 2
- 7
- 17
Keep the ticket in the Subject in a specific format that the application can understand.
e.g. Subject can be Close TICKET T1
or
Reject Resolution TICKET T1
.
You can ask the customer to specify the reason in the mail body.
the trick is to give pre-formatted Subject which you understand.

- 9,228
- 12
- 44
- 80
-
So the user can edit the ticket ID in the subject to reply to any previous ticket from other users? :) – Apollo Data Jun 18 '17 at 14:29