简体   繁体   中英

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.

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

What is the correct way to add a footer using 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?

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. For example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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