Warm tip: This article is reproduced from stackoverflow.com, please click
c# html outlook winforms

Outlook HTMLBody refuses to output the font size I specified, no matter the value

发布于 2020-04-07 10:19:32

I have this code that send email throw outlook

Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application(); 
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); 
oMsg.To = "test@test.com"; oMsg.CC = "test1@test.com"; oMsg.Subject = "Fiche De Non-Confoemité N°: " + txtOrderNumber.Text+"/"+ txtCreationDate.DateTime.Year; 
oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML; 
oMsg.Display(false); 
oMsg.HTMLBody = "<font size='18px'>"+"Un nouveau fiche de non-confoemité a été ajouté: "+ 
                "<br />" + "N°: " + txtOrderNumber.Text + "/" + txtCreationDate.DateTime.Year +
                "<br />" + "Détecteur: " + cmbDetecteurStructure.Text +
                "<br />" + "Personne Concernée: " + cmbRelevantEmployee.Text +
                "<br />" + "Date: " + txtCreationDate.Text +
                "<br />" + "Crée par « Smart Industrial Management »" +"</font>"+ oMsg.HTMLBody ;

I tried different values(14,16,18,20) but I always end up with the same size (10) in outlook.
How can I solve this problem ?.

Questioner
M.Bouabdallah
Viewed
49
Roman.Pavelko 2020-02-01 02:04

Wrap your text in some block, span for example, and add style to it:

<span style=\"font-size:16px\">Un nouveau fiche de non-confoemité a été ajouté:</span>

or just apply style to your font tag:

<font style=\"font-size:16px\">