Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to change e-mail body font type to "Tahoma".
Can any one please suggest me how can i do that.

The below is the code.
C#
MailHelper.OpenOutlookMail(strTo.ToString(), strSubject, strBody, Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML);

public static void OpenOutlookMail(string To, string Subject, string Body, Microsoft.Office.Interop.Outlook.OlBodyFormat bodyFormat)
{
    Microsoft.Office.Interop.Outlook.MailItem _message;
    Microsoft.Office.Interop.Outlook.Application _outlookInstance;
    _outlookInstance = new Microsoft.Office.Interop.Outlook.Application();
    _message = (Microsoft.Office.Interop.Outlook.MailItem)_outlookInstance.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
    _message.To = To;
    _message.Subject = Subject;
    if (bodyFormat == Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML)
        _message.HTMLBody = Body;
    else
        _message.Body = Body;
    _message.BodyFormat = bodyFormat;
    _message.Display(false);
}
Posted
Updated 20-Nov-13 20:08pm
v2

1 solution

To change the format of HTML body you can try writing like this.
C#
string Text = "<html><div style=""font-size:10.5px; font-family:Tahoma;"">" + mailItem.HTMLBody + "</div></html>"

The other approach is to replace the default font-family with your desired font-family.
In this you can do like this.
C#
mailItem.HTMLBody = mailItem.HTMLBody.Replace("Times New Roman", "Tahoma"); 

But I am not sure how far it is effective to write like this.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900