Quote original message in a reply using mailkit

独自空忆成欢 提交于 2019-12-20 03:41:37

问题


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:


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.



来源:https://stackoverflow.com/questions/31460653/quote-original-message-in-a-reply-using-mailkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!