简体   繁体   English

如何使用MimeKit添加文本页脚

[英]How To Add Text Footer Using MimeKit

I have attempted to add a footer to an email message using MimeKit, but the added footer appears as an attachment on the email, rather than just text appended to the message. 我试图使用MimeKit将页脚添加到电子邮件中,但是添加的页脚显示为电子邮件的附件,而不仅仅是在邮件中附加文本。

multipart.Add(new TextPart("text") { Text = "Hello World" });

What is the correct way to add a footer using MimeKit? 使用MimeKit添加页脚的正确方法是什么?

What you are doing in your sample code is adding a new MIME part, but what you probably want to do is append some text to an existing text/plain part, right? 您在示例代码中所做的是添加一个新的MIME部分,但是您可能想要做的是将一些文本追加到现有的text / plain部分中,对吗?

If my understanding is correct, then what you first want to do is to find the particular TextPart in the message that you want to add the footer to. 如果我的理解是正确的,那么您首先要做的是在要向其中添加页脚的消息中找到特定的TextPart。 For example: 例如:

var part = message.BodyParts.OfType<TextPart> ().FirstOrDefault ();
part.Text += Environment.NewLine + footer;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM