错误:无法从“字符串”转换到“MimeKit.MimeMessage”
我想发送电子邮件,
public readonly IMjmlServices _mjmlServices;
bodyBuilder.HtmlBody += $"</tr></ mj - table ></ mj - column ></ mj - section ></ mj - body ></ mjml >";
bodyBuilder.TextBody += $"This is some plain text";
var result = _mjmlServices.Render(bodyBuilder.HtmlBody).Result;
SmtpClient client = new SmtpClient();
try
{
client.Connect("Smtp.gmail.com", 465, true);
client.Authenticate("", "");
client.Send(result.Html);
Console.WriteLine("----- EMAIL SENT!! -----");
}
但在 client.Send(result.Html);
处出现错误,指出错误:无法从“string”转换为“MimeKit.MimeMessage” 就像
如何将此字符串转换为MimeKit.MimeMessage然后将其发送为 电子邮件?
如何将此字符串转换为MimeKit.MimeMessage,然后将其作为电子邮件发送?
I want to send a email
public readonly IMjmlServices _mjmlServices;
bodyBuilder.HtmlBody += quot;</tr></ mj - table ></ mj - column ></ mj - section ></ mj - body ></ mjml >";
bodyBuilder.TextBody += quot;This is some plain text";
var result = _mjmlServices.Render(bodyBuilder.HtmlBody).Result;
SmtpClient client = new SmtpClient();
try
{
client.Connect("Smtp.gmail.com", 465, true);
client.Authenticate("", "");
client.Send(result.Html);
Console.WriteLine("----- EMAIL SENT!! -----");
}
but at client.Send(result.Html);
it is giving error saying that Error: cannot convert from "string" to "MimeKit.MimeMessage" like
How to convert this string to MimeKit.MimeMessage and then send this as email?
How to convert this string to MimeKit.MimeMessage and then send this as email?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“如何将此字符串转换为 MimeKit.MimeMessage,然后将其作为电子邮件发送”
MjmlEmailService:
SmtpClient:
注意:
您可以查看有效的SmtpClient
请求在此参考
输出:
希望上述步骤能够相应地指导您。
"How to convert this string to MimeKit.MimeMessage and then send this as email"
MjmlEmailService:
SmtpClient:
Note:
You can have a look on validSmtpClient
requesthere in this reference
Output:
Hope above steps guided you accordingly.