IsBodyHtml = true
は間違いなく最も重要な部分です。
しかし、あなたはtext/plainの部分と交互のように構成text/htmlの部分の両方を含む電子メールを提供する場合、それはAlternateView
クラスを使用しても可能である:
MailMessage msg = new MailMessage();
AlternateView plainView = AlternateView
.CreateAlternateViewFromString("Some plaintext", Encoding.UTF8, "text/plain");
// We have something to show in real old mail clients.
msg.AlternateViews.Add(plainView);
string htmlText = "The <b>fancy</b> part.";
AlternateView htmlView =
AlternateView.CreateAlternateViewFromString(htmlText, Encoding.UTF8, "text/html");
msg.AlternateViews.Add(htmlView); // And a html attachment to make sure.
msg.Body = htmlText; // But the basis is the html body
msg.IsBodyHtml = true; // But the basis is the html body
ropstah:TBH私は混乱していましたSmtpClientにIsBodyHtmlがないというあなたのコメントの1つに書いています。ジョージアは私にMailMessageでそれを行うことを示した人です。 –