1

I have below statement to trigger mails from apex class. But here though I put size as 11, It sends mail with size 8.5.

Can someone let me know , how to achieve desired output?

code:

mail.setHtmlBody('<p style="font-family:Calibri;font-size:11">'+body+'</p>' );

By default it's making size 12.

1 Answer 1

1

This might depend on the email client that you are sending the email to, but the first two things I would try are:

1.Make the font-size important:

mail.setHtmlBody('<p style="font-family:Calibri;font-size:11px !important;">'+body+'</p>' );

2.Use the (deprecated) font tag:

mail.setHtmlBody('<font face="Calibri" size="3">'+body+'</font>');  

Note that with the <font> tag, you won't be able to pick 11px for the font size. If the difference between 11 and 12 px is too much, this option might not give you enough control to be useful.


Two other things that might be worth trying:

3.Use a span tag instead of a p:

mail.setHtmlBody('<span style="font-family:Calibri;font-size:11px;">'+body+'</span>');

4.Use internal instead of inline styling:

mail.setHtmlBody('<style>.myStyle{font-family:Calibri;font-size: 11px;}</style><span class="myStyle" >'+body+'</span>');
1
  • Still it get's defaulted to 12 size. I followed your first approach. Sep 15, 2015 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .