How to change message body - Mimekit Message

I use mimekit to receive and send mail for my project. I send the received letters with some changes (from and to the details). And now I need to change in the body section. I will replace a certain word with the symbols asterix. The specific text is different for each post. Mail can be of any format. You can see that I found what I want, but I don’t know how I can replace without any errors?

enter image description here

+4
source share
1 answer

MimeMessage.Bodyis a tree structure like MIME, so you need to go to the MimePartone containing the content you want to change.

, /* MimePart, MimePart, TextPart, .Text ( ).

, MIME , , : http://www.mimekit.org/docs/html/WorkingWithMessages.htm

:

var part = message.BodyParts.OfType<TextPart> ().FirstOrDefault ();
part.Text = part.Text.Replace ("x", "y");

, , /*, , , .

+4

Source: https://habr.com/ru/post/1624277/


All Articles