2

C# を使用して電子メールを送信し、これに必要なすべてのデータを本文にハードコーディングしています。

ただし、一部の段落 (署名) のフォントを変更する必要があります。署名の色を灰色に変更し、フォント サイズを小さいサイズに変更する必要があります。これをハードコーディングできますか?

mm.Body = "TEXT TEXT TEXT"+
"\r\n different font and color";
4

4 に答える 4

0

IsBodyHtmlこんにちは、trueに設定する必要があります。

 MailMessage msg = new MailMessage(addressFrom, addressTo, subject, body);
            msg.IsBodyHtml = isBodyHtml;

body parameter should contain actual body of your mail with style applied
于 2013-10-28T14:02:49.127 に答える
0

htmlbody を使用してフォントと色を設定します...

    namespace mysendemail
    {
     class Program
     {
      static void Main(string[] args)
      {
        SmtpMail oMail = new SmtpMail("TryIt");
        SmtpClient oSmtp = new SmtpClient();

        // Set sender email address, please change it to yours
        oMail.From = "test@emailarchitect.net";

        // Set recipient email address, please change it to yours
        oMail.To = "support@emailarchitect.net";

        // Set email subject
        oMail.Subject = "test html email from C#";

        // Set Html body
        oMail.HtmlBody = "<font size=5>This is</font> <font color=red><b>a test</b></font>";

        // Your SMTP server address
        SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net");

        // User and password for ESMTP authentication, if your server doesn't require
        // User authentication, please remove the following codes.            
        oServer.User = "test@emailarchitect.net";
        oServer.Password = "testpassword";

        // If your smtp server requires SSL connection, please add this line
        // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

        try
        {
            Console.WriteLine("start to send HTML email ...");
            oSmtp.SendMail(oServer, oMail);
            Console.WriteLine("email was sent successfully!");
        }
        catch (Exception ep)
        {
            Console.WriteLine("failed to send email with the following error:");
            Console.WriteLine(ep.Message);
        }
    }
}

}

于 2013-10-28T14:03:09.963 に答える
0
mm.Body = "<p>TEXT TEXT TEXT</p>"+
"<p style='color: green; font-size:16px'>different font and color</p>";
mm.IsBodyHtml = true;
于 2013-10-28T14:03:11.807 に答える