View Single Post
 
Old 09-06-2022, 06:15 AM
RFarrar RFarrar is offline Windows 10 Office 2021
Novice
 
Join Date: Sep 2022
Posts: 1
RFarrar is on a distinguished road
Lightbulb Outlook VBA - .RTFBody Formatting Issues from Byte Array

Hello everyone!


First post and it's a problem!


I am developing a VBA / VSTO script that interacts with Outlook.


I have a process that should, essentially, do this:
  1. Read in an .oft file that is in Rich Text Format
  2. Parse the RTFBody array into a String
  3. Replace some elements of the String (so a line that says "%SUBJECT%" will instead be "IMPORTANT MEETING")
  4. Convert that String back into the RTF array format (this uses a Rich Text Box)
  5. Replace the RTFBody with the updated RTF array
  6. Display the finished email
This is all done. Except the finished email is just RTF garbage with no formatting.

So what is meant to be a lovely table is instead this:
PHP Code:
{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff37\deff0\stshfdbch0\stshfloch37\stshfhich37\stshfbi37\deflang2057\deflangfe2057\themelang2057\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria Math;}{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304 
(You can imagine the rest.)


Does anyone have any awareness of what the solution to this problem is?


And before anyone suggests HTML... I would love to! But this is an AppointmentItem so it doesn't support HTMLBody.
Reply With Quote