Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quote original message in a reply using mailkit

There is any way to quote the original message in a reply?

e.g.:

Hi, I'm fine.

Sent at 16/07/15 from: [email protected] to: Me

Hei Jefh, how are you?

I know that I can 'attach' the original message in a new message, but I really want to quote the original message.

like image 271
Jéf Bueno Avatar asked Oct 20 '25 05:10

Jéf Bueno


1 Answers

There's no MimeKit API to quote a message, but it's not terribly difficult to do. The following code snippet is a good place to start (you may want to customize it a bit).

string QuoteMessageBody (MimeMessage message)
{
    using (var quoted = new StringWriter ()) {
        quoted.WriteLine ("On {0}, {1} wrote:", message.Date.ToString ("f"), message.From.ToString ());
        using (var reader = new StringReader (message.TextBody)) {
            string line;

            while ((line = reader.ReadLine ()) != null) {
                quoted.Write ("> ");
                quoted.WriteLine (line);
            }
        }

        return quoted.ToString ();
    }
}

Hope that helps.

like image 104
jstedfast Avatar answered Oct 21 '25 20:10

jstedfast