Munk
Munk

Reputation: 331

Send email html body as Base64 encoded

How do I in Mimekit send an email having the html body base64 encoded?

In code I first create the entire body as a MimeEnitity including attachments using the BodyBuilder. Then I create the MimeMessage to be sent having the body.

Upvotes: 0

Views: 1553

Answers (1)

jstedfast
jstedfast

Reputation: 38643

The first thing you'll need to do is to locate the HTML body part.

A quick hack might look something like this:

var htmlBody = message.BodyParts.OfType<TextPart> (x => x.IsHtml).FirstOrDefault ();

Then you'll need to set the Content-Transfer-Encoding:

htmlBody.ContentTransferEncoding = ContentEncoding.Base64;

That's it.

Upvotes: 1

Related Questions