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,326 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Rune Terkel Jørgensen 1 Reputation point
    2022-10-31T14:54:12.403+00:00

    Hi @Vincent

    I have just encountered the same issue with a customer that is using the same macro to forward emails from a copier that only delivers TXT format mail.
    The PC is running Win 10 and with Outlook 2016.

    Have you found a solution?

    Best regards
    Rune

    0 comments No comments

  2. _ DUCMANs _ 1 Reputation point
    2022-11-13T10:48:28.707+00:00

    I use the same macro and it happens here as well.

    It is at this point in the code where it turns to Chinese: olMsg.BodyFormat = olFormatHTML

    Still trying to find out why though.

    On Windows 10 end Office 2021.

    0 comments No comments

  3. Markus macht IT 1 Reputation point
    2022-11-18T14:42:56.457+00:00

    Same problem here since Update to OL Version 2210 (Build 15726.20174)
    No problem with previous versions.

    0 comments No comments

  4. Vincent 1 Reputation point
    2022-11-18T17:30:59.19+00:00

    Thank you for your interest in this issue.
    Unfortunately I have not yet found a solution to the problem!

    0 comments No comments

  5. Vincent 1 Reputation point
    2022-11-28T18:26:43.27+00:00

    Bonjour,

    J’ai utilisé la macro indiqué dans ce commentaire et je l’ai modifié comme ci-dessous, et ça fonctionne à nouveau sans transformer en Chinois!

    Sub AlwaysReplyInHTML_Kutools()  
    Dim xSelection As Outlook.Selection  
    Dim xItem As Object  
    Dim xMail As Outlook.MailItem  
    Dim xMailReply As Outlook.MailItem  
      
    'On Error Resume Next  
    Select Case TypeName(Application.ActiveWindow)  
      Case "Explorer"  
        Set xSelection = Application.ActiveExplorer.Selection  
        If xSelection.Count > 0 Then  
          Set xItem = xSelection.Item(1)  
        Else  
          MsgBox "Please select an item first!", vbCritical, "Kutools for Outlook"  
          Exit Sub  
        End If  
      Case "Inspector"  
        Set xItem = Application.ActiveInspector.CurrentItem  
      Case Else  
        MsgBox "Unsupported Window type." & vbNewLine & "Please select or open an item first.", vbCritical, "Kutools for Outlook"  
        Exit Sub  
    End Select  
      
    If xItem.Class = olMail Then  
      Set xMail = xItem  
      'Changer le format ici, afin que la réponse inclut notre signature en html!  
            xMail.BodyFormat = olFormatHTML  
        
      Set xMailReply = xMail.Reply  
      xMailReply.Display  
      'xMailReply.BodyFormat = olFormatHTML  
    Else  
      MsgBox "No message item selected. Please select a message first.", vbCritical, "Kutools for Outlook"  
      Exit Sub  
    End If  
      
    Set xMailReply = Nothing  
    Set xMail = Nothing  
    Set xItem = Nothing  
    Set xSelection = Nothing  
    End Sub  
    
    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.