Search code examples
c#text-formattingmailmessage

Hardcoding Text and formatting


I am sending an email with C# and hardcoding all the data needed for this to include in my Body.

However I need to change some fonts of some paragraphs(signature). I need to change the color of the signature to gray and changing the font size to a smaller size. Can this be done hardcoded?

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

Solution

  • Setting isBodyHtml to true allows you to use HTML tags in the message body:

    msg = new MailMessage("xxxx@gmail.com",
                    "yyyy@gmail.com", "Message from PSSP System",
                    "This email sent by the PSSP system<br />" +
                    "<b>this is bold text!</b>");
    
    msg.IsBodyHtml = true;
    

    Read this

    And also try this :

    msg.BodyFormat = MailFormat.Html;