Quote original message in a reply using mailkit

2019-07-09 03:05发布

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

e.g.:

Hi, I'm fine.

Sent at 16/07/15 from: user@mail.com 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.

1条回答
再贱就再见
2楼-- · 2019-07-09 04:02

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.

查看更多
登录 后发表回答