1

I am using mailitem.HTMLBody to process the text of an email body.

The entire body of the email can be accessed through mailitem.HTMLBody.

How can I change the font of the entire email body in C#? e.g Set font size as 10.5 and font as Consolas

Outlook.MailItem mailItem = (Outlook.MailItem)selection[1];

mailItem.HTMLBody = "<font size= 10>";

This does not work.

1
  • I hope that's not the real example that you're testing with - HTML tags without any text content won't render anything. You're changing the font for an empty page. (And, as @Spudley mentioned, font is deprecated. ) Commented Jun 28, 2011 at 14:30

1 Answer 1

3

No.

Don't use <font> tags. This tag has been obsolete for a very long time now.

Instead, use a CSS stylesheet. This would be a separate file which you'd include (it can also be embedded in your main page using the <style> tag in your header, but it's better practice to have it as a separate file)

To set the font globally io your page using CSS, you can do this:

body {
    font-size: 10px;
}

Hope that helps.

Sign up to request clarification or add additional context in comments.

3 Comments

I have added the CSS style sheet, How do I call the stylesheet from my function which accesses the HTML body?
is it like mailItem.HTMLBody="<Stylesheet1>"?
@thinkcool - it's "<style>body {font-size:10px;}</style>", and it goes in the page header section, not in the htmlbody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.