Quote original message in a reply using mailkit

前端 未结 1 1013
日久生厌
日久生厌 2021-01-23 06:26

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

相关标签:
1条回答
  • 2021-01-23 06:52

    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.

    0 讨论(0)
提交回复
热议问题