2
votes

We have written an Outlook add-in in C#, that appends a custom header to outgoing messages.

This add-in has to use a library called Redemption to bypass Outlook's security to modify the headers, and this is all working great.

Our problem lies when sending outgoing mail through an exchange server. We use the additional header as such:

  • Add a References header with an email address that includes an ID for tracking with our system.
  • This is a standard email header that all mail clients should pass on when replying to messages. So replying to a message will automatically keep the new message tracked.

All of this works just fine if you send an email from an IMAP account setup in Outlook such as GMail.

Problem is, if you send mail via an Exchange account, the Exchange server overwrites the References header and uses it's own proprietary headers: Thread-Index and Thread-Topic. Email standards suggest to use References and In-Reply-To headers. See this link on this issue.

Does anyone know a way around this? Some algorithm to gain us the following:

  • Add a header (of any name or kind) to emails that includes a 10-digit ID and 3 letter prefix
  • Replying to this email from all (or most) mail clients preserves the custom header
1

1 Answers

1
votes

I think the following algorithm is going to solve our issue:

  • Our Outlook add-in will set the References and an arbitrary X- header
  • Our mail filter will look for References, if found use it (if outgoing mail server was Exchange, it will not be present)
  • If our mail filter finds the arbitrary X- header and a Thread-Index, it will store the data found in the X- header.
  • Later if the email is replied-to several times, the mail filter will use the Thread-Index to look up the past info to keep the email tracked.

For those wanting to know internals of the Thread-Index header, it is a Base64 encoded string. The first 22 bytes are the original unique portion and each reply adds an additional 5 bytes on to it. We only use the first 22 bytes to identify the email.