Macro to automatically reply in HTML

Vincent 1 Reputation point
2022-09-14T08:25:23.977+00:00

Hello,

I use a macro in Outlook to automatically reply in HTML to a plain text message.

You can find this explanations:
replyinhtml.htm and
1618-outlook-reply

Since a few days (probably due to a Windows update) it doesn't work anymore. The message is transformed as if there was a modification of the coding...

For example a message containing in plain text:
"Bonjour et Merci"

will become:

"ℼ佄呃偙⁅呈䱍倠䉕䥌⁃ⴢ⼯㍗⽃䐯䑔䠠䵔⁌⸳⼲䔯≎ാ㰊呈䱍ാ㰊䕈䑁ാ㰊䕍䅔䠠呔ⵐ充䥕㵖䌢湯整瑮吭灹≥䌠乏䕔呎∽整瑸栯浴㭬挠慨獲瑥甽晴㠭㸢਍䴼呅⁁䅎䕍∽敇敮慲潴≲䌠乏䕔呎∽卍䔠捸慨杮⁥敓癲牥瘠牥楳湯ㄠ⸶⸰㔱〶⸱〲㜰∲ാ㰊䥔䱔㹅⼼䥔䱔㹅਍⼼䕈䑁ാ㰊佂奄ാ㰊ⴡ潃癮牥整⁤牦浯琠硥⽴汰楡潦浲瑡ⴠ㸭਍਍值㰾但呎匠婉㵅㸲潂橮畯⁲瑥䴠牥楣䈼㹒਍䈼㹒਍⼼但呎ാ㰊倯ാഊ㰊䈯䑏㹙਍⼼呈䱍>"

Then the macro opens the reply to the message, with my signature, in ordinary characters but in plain text and not in html...!

Would you know what change to make to fix this?

Thanks a lot.

Windows10 et Microsoft® Outlook® pour Microsoft 365 MSO (Version 2208 Build 16.0.15601.20072) 64 bits

(Sorry for my bad english translated from french…)

Below is the code for the macro:
Sub ForceReplyInHTML()

'=================================================================
'Description: Outlook macro to reply to a message in HTML
' regardless of the current message format.
' The reply will use your HTML signature as well.
'
'author : Robert Sparnaaij
'version: 1.0
'website: https://www.howto-outlook.com/howto/replyinhtml.htm
'=================================================================

Dim objOL As Outlook.Application  
Dim objSelection As Outlook.Selection  
Dim objItem As Object  
Set objOL = Outlook.Application  
  
'Get the selected item  
Select Case TypeName(objOL.ActiveWindow)  
    Case "Explorer"  
        Set objSelection = objOL.ActiveExplorer.Selection  
        If objSelection.Count > 0 Then  
            Set objItem = objSelection.Item(1)  
        Else  
            Result = MsgBox("No item selected. " & _  
                        "Please make a selection first.", _  
                        vbCritical, "Reply in HTML")  
            Exit Sub  
        End If  
      
    Case "Inspector"  
        Set objItem = objOL.ActiveInspector.CurrentItem  
          
    Case Else  
        Result = MsgBox("Unsupported Window type." & _  
                    vbNewLine & "Please make a selection" & _  
                    " or open an item first.", _  
                    vbCritical, "Reply in HTML")  
        Exit Sub  
End Select  

Dim olMsg As Outlook.MailItem  
Dim olMsgReply As Outlook.MailItem  
Dim IsPlainText As Boolean  
  
'Change the message format and reply  
If objItem.Class = olMail Then  
    Set olMsg = objItem  
    If olMsg.BodyFormat = olFormatPlain Then  
        IsPlainText = True  
    End If  
    olMsg.BodyFormat = olFormatHTML  
    Set olMsgReply = olMsg.Reply  
    If IsPlainText = True Then  
        olMsg.BodyFormat = olFormatPlain  
    End If  
    olMsg.Close (olSave)  
    olMsgReply.Display  
      
'Selected item isn't a mail item  
Else  
    Result = MsgBox("No message item selected. " & _  
                "Please make a selection first.", _  
                vbCritical, "Reply in HTML")  
    Exit Sub  
End If  
  
'Cleanup  
Set objOL = Nothing  
Set objItem = Nothing  
Set objSelection = Nothing  
Set olMsg = Nothing  
Set olMsgReply = Nothing  
     

End Sub

Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,406 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Vincent 1 Reputation point
    2022-11-28T18:27:23.527+00:00

    Les couleurs sont toutes bizzares… mais la macro se lit assez bien!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.