如何通过Mimekit/Mailkit发送HTML消息 [英] How to send HTML message via Mimekit/Mailkit

查看:341
本文介绍了如何通过Mimekit/Mailkit发送HTML消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BodyBuilder bodyBuilder = new BodyBuilder();
messageContent.Body = "<b>This is a test mail</b>";
bodyBuilder.HtmlBody = messageContent.Body;

我试图将自己的身体嵌入健美运动员中,但是当我收到电子邮件时,它返回了一个空的身体.我有一个例外,如果主体为空,则会引发参数.

I tried to embed my body to a bodybuilder but when I received the email, it returned an empty body. I have an exception that would throw an argument if the body is empty..

推荐答案

像执行操作一样使用BodyBuilder可能是最简单的方法.

Using a BodyBuilder like you are doing is probably the easiest way.

var bodyBuilder = new BodyBuilder ();
bodyBuilder.HtmlBody = "<b>This is some html text</b>";
bodyBuilder.TextBody = "This is some plain text";

message.Body = bodyBuilder.ToMessageBody ();

client.Send (message);

这篇关于如何通过Mimekit/Mailkit发送HTML消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆