PDA

View Full Version : Change Outlook Reply Format to RTF



jason_kelly
08-09-2011, 08:39 AM
Hello,

I need your help.

I am aware that there is no option for Outlook to force outlook to reply to a message in RTF format.

That being said, can some vba be written, such that when I select a message from my inbox and hit the 'Reply' or 'Reply to All' buttons in outlook that it will change the outgoing message format to RTF?

I cant seem to find a code there that will automatically do that.

Any help with this is greatly appreciated.

Cheers,

Jason

dougbert
08-09-2011, 08:22 PM
Hey Jason,

If this works for you, please use the Thread Tools menu just above your first post to mark this thread as 'Solved'. A rating would be a nice way to return the favor too. :rotlaugh:

First, one caveat to consider:
http://www.outlook-tips.net/2011/1943/change-reply-format

I found some code that I think will work with a single modification. The code is posted at: http://www.ehow.com/how_6620462_do-outlook-2007-reply-html_.html

I modified this one line of code from:
objBodyFormat = olFormatHTML
to:
objBodyFormat = olFormatRichText

FYI: I'm using Outlook 2010, though that is unlikely to matter as long as you are at least at 2000/2003, but I don't have them to test with any longer.

I tested it on a reply to an html message and it worked! So, I sent myself a Plain Text message, clicked Reply and it worked too!

As soon as I clicked Reply the format of the sender's message changed. I verified I was in RTF while in the reply by clicking the Format Text tab, looking in the Format area and 'Rich Text' was highlighted.

So, if you're still convinced you want to do this, here's the code as it worked for me. Make sure you compile it, as initially I had some ambiguous names due to other macros I have in the module. Placing a comment ' before a couple of 'Private With Events' lines that were trying to declare other definitions allowed it to work. If you don't have any other code in this module, you should just be able to paste, compile, close Outlook, save the OTM project on exit, wait a few seconds, re-open Outlook and start replying, keeping the caveat at the beginning of my post in mind.

Make sure you paste this in the ThisOutlookSession module, compile and that you have Macro Settings set to 'enable all macros' in order for it to work.

Here you go:



Option Explicit
Private WithEvents objExplorer As Explorer
Private WithEvents objMailItem As MailItem
Private blnDiscardEvents As Boolean
Private objBodyFormat As OlBodyFormat
Private Sub Application_Startup()
Set objExplorer = Application.ActiveExplorer
blnDiscardEvents = False
objBodyFormat = olFormatRichText
End Sub
Private Sub objExplorer_SelectionChange()
On Error Resume Next
Set objMailItem = objExplorer.Selection.Item(1)
End Sub
Private Sub objMailItem_Reply(ByVal Response As Object, Cancel As Boolean)
If blnDiscardEvents Or objMailItem.BodyFormat = objBodyFormat Then
Exit Sub
End If
Cancel = True
blnDiscardEvents = True
Dim oResponse As MailItem
Set oResponse = objMailItem.Reply
oResponse.Display
oResponse.BodyFormat = objBodyFormat
blnDiscardEvents = False
End Sub
Private Sub objMailItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
If blnDiscardEvents Or objMailItem.BodyFormat = objBodyFormat Then
Exit Sub
End If
Cancel = True
blnDiscardEvents = True
Dim oResponse As MailItem
Set oResponse = objMailItem.ReplyAll
oResponse.Display
oResponse.BodyFormat = objBodyFormat
blnDiscardEvents = False
End Sub
Private Sub objMailItem_Forward(ByVal Forward As Object, Cancel As Boolean)
If blnDiscardEvents Or objMailItem.BodyFormat = objBodyFormat Then
Exit Sub
End If
Cancel = True
blnDiscardEvents = True
Dim oResponse As MailItem
Set oResponse = objMailItem.Forward
oResponse.Display
oResponse.BodyFormat = objBodyFormat
blnDiscardEvents = False
End Sub


Enjoy!
-dougbert