"Always reply using HTML" code sample

May 18, 2011
By

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


Remove the To field from an Outlook message form » »

Resources

Ask questions and share your knowledge in Outlook Forums.

Follow Me On

Ajax spinner


Tips Archive