SMTP替代SendGridMessage对象的PlainTextContent和HtmlContent属性

问题描述

我正在满足一个要求,即我必须在.Net Core项目中编写用于通过SMTP发送邮件代码,它将替换已编写的代码以通过SendGrid发送邮件。虽然我已经找到了大多数可以替代SendGrid邮件发送代码内容,但是在弄清楚如何处理PlainTextContent对象的HtmlContentSendGridMessage属性时遇到了困难,即:

 var msg = new SendGridMessage()
            {
                From = new EmailAddress("[email protected]","DX Team"),Subject = "Hello World from the SendGrid CSharp SDK!",PlainTextContent = "Hello,Email!",HtmlContent = "<strong>Hello,Email!</strong>"
            };

另一方面,我用来通过SMTP发送邮件MailMessage类没有任何类似的属性。我最大可以做的是:

MailMessage smtpMsg = new MailMessage(from,to);
smtpMsg.IsBodyHtml = true;
smtpMsg.Body = "<strong>Hello,Email!</strong>";

如果我要设置类似于SendGrid的邮件的纯文本内容怎么办?我该怎么办?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)