• HTML emails sent via VBA display as MIME text since 17126.20132 update

    Home » Forums » AskWoody support » Microsoft Office by version » Office 2019 for PC » HTML emails sent via VBA display as MIME text since 17126.20132 update

    Author
    Topic
    #2631950

    I have an Excel VBA Macro that sends HTML email messages using the Outlook.Application object and referencing the Microsoft Office 16.0 Object Library, Microsoft Office 16.0 Outlook Library, and the Microsoft Excel 16.0 Object Library.

    This VBA Macro has run for several years without modifications and without problems.

    At the end of December, it worked fine. At the end of January, the emails look OK in the Draft folder but once sent, they appear to the recipient as text (uninterpreted MIME text). If I send them to myself, they also appear as text (uninterpreted MIME text).

    I tried sending with an outlook.com, gmail.com, aol.co.uk and yahoo.com From: and all had the same result. That lead me to believe that it wasn’t the email service but maybe Outlook itself that had changed. I checked the properties of the Outlook.exe and found that my Outlook had been updated on 01/09/2024 to build 17126.20132.

    The first few lines of the received message look like this instead of displaying the HTML body properly:

    Code:
    Date: Sat, 27 Jan 2024 09:49:07 -0500
    
    Message-ID: <001401da512f$fbfe22e0$f3fa68a0$@yahoo.com>
    
    MIME-Version: 1.0
    
    Content-Type: multipart/alternative;
    
    boundary="----=_NextPart_000_0015_01DA5106.132841F0"
    
    X-Mailer: Microsoft Outlook 16.0
    
    Thread-Index: AdpRL+CLDwHNFptQRByy4dYfv3ajqg==
    
    Content-Language: en-us
    
    This is a multipart message in MIME format.
    
    ------=_NextPart_000_0015_01DA5106.132841F0
    
    Content-Type: text/plain;
    
    charset="us-ascii"
    
    Content-Transfer-Encoding: 7bit

    _____________________________________________________

    Sample section of VBA Macro:

    Code:
    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItem(olMailItem)
    With objMail
    .To = EMAILACCOUNT
    .BCC = strEmailAddresses
    .Subject = GetSubject()
    .Body = GetBody()
    .BodyFormat = olFormatHTML
    .HTMLBody = GetBody()
    .SendUsingAccount = objOutlook.Session.Accounts.Item(lngAccountID)
    .DeferredDeliveryTime = CDate(DeferDateTime)
    .Importance = olImportanceNormal
    End With
    
    If Testing Then
    objMail.Save ' Save to Drafts Folder
    Else
    objMail.Send
    End If

    ____________________________________________________

    Office 2019 16.0.17126.20132

    Windows 11 Pro

    Version 23H2

    OS build 22631.2861

    Experience Windows Feature Experience Pack 1000.22681.1000.0

    Viewing 5 reply threads
    Author
    Replies
    • #2632008

      Additional information:
      <p data-prewrap=”true” data-pm-slice=”1 1 []”>#1 Testing Plain Text messages</p>
      <p data-prewrap=”true”>In further testing, I found that when sending Plain Text emails using the VBA Macro, the recipient sees this in the body of the email message in the lines before the message text:</p>

      Code:
      Message-ID: <005301da513f$730a5f20$591f1d60$@yahoo.com>
      MIME-Version: 1.0
      Content-Type: text/plain;
      charset="us-ascii"
      Content-Transfer-Encoding: 7bit
      X-Mailer: Microsoft Outlook 16.0
      Thread-Index: AdpRP2BAHG1WzBkLQxG+k6UZuC1Z3A==
      Content-Language: en-us

      <p data-prewrap=”true”>#2 Testing bypassing Outlook; connecting directly to SMTP Server</p>
      <p data-prewrap=”true”>Instead of the Outlook.Application object, I used the Microsoft CDO for Windows 2000 library to connect directly to the SMTP server (bypassing the Windows Outlook app). Although this library is very old and no longer supported, I was able to send HTML messages that display properly when the recipient opens them. I think this demonstrates that either the Microsoft Office 16.0 Object library, Microsoft Outlook 16.0 Library or the Windows Outlook application is at fault.</p>

    • #2632057

      You are setting Body and HTMLBody to the same (I assume it’s HTML).
      Try not setting Body.

      cheers, Paul

      • #2632095

        Setting only HTMLbody and not setting Body does not solve the issue.

    • #2632100

      The other way around – no HTMLBody?

      cheers, Paul

    • #2632103

      No. That doesn’t solve the issue  either.  Both plain text and HTML messages display improperly for the recipient but display properly in the Drafts folder. Both plain text and HTML messages displayed properly for the recipient at the end of December but do not display properly for the recipient after the Office update.

    • #2715925

      After a bunch of debugging, I found that my GetSubject() function was returning a string that terminated in vbCrLf. Removing the vbCrLf at the end of the Subject solved this issue.

      That had not been a problem prior to the 17126.20132 update.

      1 user thanked author for this post.
    • #2715929

      That is a pretty specific mis-interpretation by Outlook. Do other email clients have the same issue?

      cheers, Paul

    Viewing 5 reply threads
    • The topic ‘HTML emails sent via VBA display as MIME text since 17126.20132 update’ is closed to new replies.