C# html email font size

To change the font size in an HTML email sent using C#, you can use the <font> tag or the <span> tag with the style attribute.

Here is an example of how you can do it:

string body = "<html><body>";
body += "<font size=3>Large font size</font>";
body += "<span style='font-size: 2em'>Medium font size</span>";
body += "<font size=1>Small font size</font>";
body += "</body></html>";

In this example, we are using the <font> tag with the size attribute to set the font size to 3, 2, and 1 respectively. We are also using the <span> tag with the style attribute to set the font size to 2em.

You can also use CSS to style the font size, for example:

string body = "<html><body>";
body += "<style>body { font-size: 16px; }</style>";
body += "<p>Normal font size</p>";
body += "<p style='font-size: 18px'>Large font size</p>";
body += "<p style='font-size: 14px'>Small font size</p>";
body += "</body></html>";

In this example, we are using the <style> tag to define a CSS style for the body of the email, and then using the style attribute on the <p> tags to set the font size.

You can also use the MailMessage.BodyFormat property to set the format of the email body to HTML, and then use the MailMessage.Body property to set the HTML content of the email.

MailMessage mail = new MailMessage();
mail.BodyFormat = MailFormat.Html;
mail.Body = body;

Make sure to set the Content-Type header of the email to text/html to indicate that the email body is in HTML format.

mail.Headers.Add("Content-Type", "text/html; charset=UTF-8");

You can then send the email using the SmtpClient class.

SmtpClient client = new SmtpClient();
client.Send(mail);

Note that the font size may not be preserved when the email is rendered in different email clients, as different clients may have different default font sizes and styles.