"Always reply using HTML" code sample

See Outlook's Reply Format for reasons why you shouldn't change the format.

Originally posted as a comment in Tip 434: Change Reply Format August 2007

This code sample was checked (by me) against Outlook 2007 and 2010.  Others report that it works with Outlook 2003.

To switch this code to always use plain text, locate and change this line in the code to comment out the HTML code (2) and remove the comment from plain text format (1). Note that Outlook 2003 and later have the ability to always use plain text.

olFormat = olFormatPlain        '(*1) - always use plain text'olFormat = olFormatHTML        '(*2) - always use HTML

Copy and paste the code from this page into your ThisOutlookSession project. To do this, click in the text box, Select All using Ctrl+A, Ctrl+C to copy.

In Outlook, press Alt+F11 to open the VBA editor and expand Microsoft Outlook Objects then double click on ThisOutlookSession to open it in the editing pane and Ctrl+P to paste the code.

How to use VBA code samples in Outlook

Option Explicit 

Private WithEvents oExpl As Explorer 
Private WithEvents oItem As MailItem 

Private bDiscardEvents As Boolean 
Private olFormat As OlBodyFormat 


Private Sub Application_Startup() 

Set oExpl = Application.ActiveExplorer 

bDiscardEvents = False 

'olFormat = olFormatPlain '(*1) - uz.ywaj zawsze formatu "zwyk?y tekst" 
olFormat = olFormatHTML '(*2) - uz.ywaj zawsze formatu HTML 

End Sub 

Private Sub oExpl_SelectionChange() 

On Error Resume Next 
Set oItem = oExpl.Selection.Item(1) 

End Sub 

' (*3) Uz.ytkownik wybra? polecenie "Odpowiedz" 
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean) 

If bDiscardEvents Or oItem.BodyFormat = olFormat Then 
Exit Sub 
End If 

'(*4) Anuluj domys'lna; akcje; 
Cancel = True 

bDiscardEvents = True 

' (*5) Utwo'rz odpowiedz' na wiadomos'c' w formacie tekstowym 
Dim oResponse As MailItem 
Set oResponse = oItem.Reply 
oResponse.BodyFormat = olFormat 
oResponse.Display 

bDiscardEvents = False 

End Sub 

' (*6) Uz.ytkownik wybra? polecenie "Odpowiedz wszystkim" 
Private Sub oItem_ReplyAll(ByVal Response As Object, Cancel As Boolean) 

If bDiscardEvents Or oItem.BodyFormat = olFormat Then 
Exit Sub 
End If 

Cancel = True 

bDiscardEvents = True 

Dim oResponse As MailItem 
Set oResponse = oItem.ReplyAll 
oResponse.BodyFormat = olFormat 
oResponse.Display 

bDiscardEvents = False 

End Sub 

' (*7) Uz.ytkownik wybra? polecenie "Przes'lij dalej" 
Private Sub oItem_Forward(ByVal Forward As Object, Cancel As Boolean) 

If bDiscardEvents Or oItem.BodyFormat = olFormat Then 
Exit Sub 
End If 

Cancel = True 

bDiscardEvents = True 

Dim oResponse As MailItem 
Set oResponse = oItem.Forward 
oResponse.BodyFormat = olFormat 
oResponse.Display 

bDiscardEvents = False 

End Sub

You can copy and paste from the text box above or download a text file containing the VBA code: http://www.outlook-tips.net/files/always-reply-using-html.txt

Change the Reply Font

When you use the macro, Outlook uses the default plain text font, not your HTML font setting. To change the font, you need to add the font format to the HTMLBody line, as seen in the sample below. This example will change both the font and the font color. Outlook should use your default font size for the reply text. p>

oResponse.HTMLBody = "<font face=" & Chr(34) & " verdana" & Chr(34) & "> <font color=" & Chr(34) & " green" & Chr(34) & "> " & oResponse.HTMLBody
Font sample

Note: If you add the font size tag, it will change the size of the font you'll use for your response but not the font size of the quoted text. When you click Send, Outlook will rewrite this to CSS.

Last reviewed on March 27, 2014.

  • Todor

    tested on 2003?

  • http://www.outlook-tips.net dianep

    Yes, according to the comments in the original post, it does work in Outlook 2003 (along with 2007 and 2010, which i tested it with).

  • http://www.outlook-tips.net dianep

    Another comment from the old blog, author unknown:

    "Very nice piece of code. However, I had my own fonts specified and by running this, they kept changing to the default "Times New Roman". A small change to the code fixed that for me.

    Just flip the order of the following code:

    oResponse.BodyFormat = olFormat
    oResponse.Display

    to

    oResponse.Display
    oResponse.BodyFormat = olFormat

    and my own specified font formats stays. It takes less than a fraction of a second to change the format. So displaying it first does not cause any problem. "

  • Nasar

    Thanks for this.

    I have save the code exactly as it says above into this ThisOutlookSession project in Outlook 2010. But how do i run this? When i click ALT+F8 it comes up empty. Also when i open a plain text email and click reply or reply all it still opens up as Plain text instead of HTML which is what i want. Appreciate all your help

  • Diane

    It runs automatically when you reply to a message. You also need to have macro security set to medium or sign the macro. (Medium, warn for all macros, is better for most users or while tweaking macros.) Set macro security to medium and restart outlook. A VBA dialog will comes up, ok it and then the macro should work.

  • marie h w hut

    ik ging naar Bar le Duc water en wilde een email versturen,maar kreeg iets met replycode niet goed of zo telenet 220 met 2 namen beide telenet.Vandaar mijn zoektocht wat is reply code Zag er 2 replycode Alpha en reply invalid codes.Ik ben geeindigd met snap er niks van vr.gr.mariehut

  • Diane Poremsky

    Something may have gotten lost in translation... but if i understand it correctly, you couldn't send an email while using public internet? This is common - many sites block smtp port 25 and make you use a different one or authenticate with your server. If its something else, sorry :(

  • Tony D.

    This works great on Outlook 2010 (14.0) 32 bit version except that my custom fonts on the signatures do not propagate. HTML yes, my fonts and colors no. Any ideas?

  • Diane Poremsky

    Are you using the
    oResponse.Display
    oResponse.BodyFormat = olFormat
    change?

    I'll have to check it, but it could be because the signature is added before the conversion.

  • Tony D.

    Yes I made that change in all 3 places.
    I also found both the original and changed version will not run under 64bit Outlook 2010 :/
    Thanks for you help!!

  • http://www.prime-networks.co.uk Ben

    Hi

    We still cannot get the HTML Signature to come up when using this code. The code does work and i can confirm the email is now in HTML, but its still using the plan text version of the sig?

    Any way to fix this?

  • Diane Poremsky

    Based on discussions with Outlook developers, they believe the signature is added before the code makes the conversion.

    Right click on the signature - do you see the signature menu or the standard context menu?

  • Mark

    I found this page in the search for making all my replies HTML so that I could always include my classy html signature with image links for self-promotion purposes.

    I simply hate the vba editor and all the silly macro stuff, I always seem to get some error message. I fiddled round for hours trying to get this script (and another modified one on some other site) to work, but at best, it would make the font Times New Roman no matter what order of those two lines there, and my html signatures still don't work fully anyway, which was the whole point of the exercise. So it's not really very adequate.

    But I found a cool solution, albeit a commercial one: a brilliant third-party outlook add-on, bells & whistles: http://www.emailaddressmanager.com/outlook-bells.html. 30 bucks was worth it for me. it does some other cool things which I'm using now too.

    It does the change from plain text to html in some other way which is as if you clicked the html button in the ribbon on every email. I guess it loads the macro at the loading of every new message reply. And what satisfies my needs is its signature option. voila!

    it very smartly inserts the third party html signature that you make and assign, as a second step after the change to html. so it's PERFECT in other words!!!!!

    hope my comment helps someone out there.

  • Andy Wright

    Thanks for this, with the altering of Macro security this now works just fine.
    I had the problem mentioned by other poster whereby the signiature is inserted in plain text not HTML.
    My way round the problem is to set outlook to not automatically add a sig to replies.
    I then click reply and then click insert signiature
    The sig has a few lines of text in my preferred font above the sig image, so I can then just click in that section and start typing in the desired font.
    Yes this is a bit of a faff, but it leaves me with $30 to spend on beer instead :)

  • http://www.outlook-tips.net Diane Poremsky

    Beer is better than outlook. :) Depending on your version of Outlook, you can customize the toolbar, ribbon, or QAT to make the Insert signature command a step away, reducing your effort further.

  • josh wilson

    i love the the above code, any way to insert me signal to it

  • Christoph

    Thanks for this script.
    I'm using it but when I reply to an email, the font changes to Times New Roman.
    I need Verdana, 10pt, grey. How can I change that?
    In the settings of Outlook 2010 are the right font settings.

  • http://www.outlook-tips.net Diane Poremsky

    This happens because Outlook uses word as the editor - you can change the font fairly easily, but changing the font size is a little more complicated and i don't have a sample that does that. You'll add the oResponse.HTMLBody line as shown in this snippet - and can remove the bodyformat line.

    Dim oResponse As MailItem
    Set oResponse = oItem.Reply
    oResponse.HTMLBody = " " & " " & oResponse.HTMLBody

    oResponse.Display
    bDiscardEvents = False

  • zsolt

    This code does not work, there is a synthax error in the font definition line and also in. bDiscardEvents = False

  • http://www.slipstick.com/ D Poremsky

    it looks like the conversion from WordPress to Disqus messed the code up. Every "&" should be "&" - it was converted to the html code for &. (The = multiplied too.)

  • http://www.slipstick.com/ D Poremsky

    The correct code (assuming it doesn't get messed up again) is

    oResponse.HTMLBody = &quot;&lt;font face=&quot; &amp; Chr(34) &amp; &quot; verdana&quot; &amp; Chr(34) &amp; &quot;&gt; &lt;font color=&quot; &amp; Chr(34) &amp; &quot; green&quot; &amp; Chr(34) &amp; &quot;&gt; &quot; &amp; oResponse.HTMLBody

    The 2 closing font tags were added by the web software too. Outlook will rewrite the color tags to CSS and properly close the tags when you hit Send.
    I updated the article to include this line of code.