This project is read-only.

How to properly generates a Reply message from a message received from IMapX

Topics: Feature Requests, Issues
May 26, 2016 at 2:58 PM
Hi There,

Thank you alot for your awesome library.

I've a simple need, I just want to generate a Reply message from a message I've retrieved by IMapX.

So that it can be properly associated to a Thread and displayed as this in GMail for instance.

a) I tried to send the reply with "Re: + Blah" in subject -> No Success (considered as a separate conversation)
b) I tries to send the reply by appending with the body of the message I wanna reply to -> No Success

How can I proceed ?

Thanks
May 26, 2016 at 7:20 PM
There are a few things you'll need to do when constructing a reply:
  1. In the reply message, you'll want to prefix the Subject header with "Re: " if the prefix doesn't already exist in the message you are replying to (in other words, if you are replying to a message with a Subject of "Re: party tomorrow night!", you would not prefix it with another "Re: ").
  2. You will want to set the reply message's In-Reply-To header to the value of the Message-Id header in the original message.
  3. You will want to copy the original message's References header into the reply message's References header and then append the original message's Message-Id header.
That should make GMail and all other mail software properly thread your message.
May 26, 2016 at 8:12 PM
Edited May 26, 2016 at 8:13 PM
Thank you jstedfast,

This works pretty well!

Anyway, I'm wondering how to append with the message history in the body as Gmail or Outlook does.

I suppose, I'll need to manage that manually, dealing with HTML or plain text. Generating '>' at the beginning of each line and properly generates header Send By blah blah...

Any tip on that ?
May 27, 2016 at 7:29 PM
Right, you can just do something like this:
var quoted = new StringBuilder ();
using (var reader = new StringReader (text)) {
    string line;

    while ((line = reader.ReadLine ()) != null) {
        quoted.Append ("> ");
        quoted.AppendLine (line);
    }
}
May 30, 2016 at 4:54 PM
Great thanks !