I am using VB6, MS SQL Server and MS Office 2003.

I have the following function that accepts several Outlook related parameters and uses them to prepare a note and either send it or display it depending on the contents of the "Method" param. I was originally getting all of the data from various fields from a SQL database, putting in some HTML formatting tags and sending it on its merry way. That worked wonderfully.

Then I was asked to provide the users a way to format part of the text on their own from within my application. I found a neat control from TX Text Control to use for my purposes and save the contents of that text control as an .RTF file. My issue now is how to retain or recreate the formatting I have as HTML while programmatically inserting the contents of the .RTF file at a specific point in the Outlook note?

My current code which works just fine...

VB Code:
  1. Function SendHTMLeMail(ToList As String, CCList As String, BCCList As String, _
  2.                    SubjectText As String, MsgText As String, Method As String) As Boolean
  3. '***************************************************************
  4. '    Purpose: Sends or displays an Oulook message
  5. '      INPUT: ToList:     ID's that will go on the To: line
  6. '             CCList:     ID's that will go on the CC: line
  7. '             BCCList:    ID's that will go on the BCC: line
  8. '             SubjectText:Text for the subject line
  9. '             MsgText:    Text for the body of the message
  10. '             Method:     String to determine to Send or Display
  11. '     Output: True or False
  12. '***************************************************************
  13.  
  14.   Dim olMAPI As New Outlook.Application
  15.   Dim itmMail As Outlook.MailItem
  16.  
  17.   Set itmMail = olMAPI.CreateItem(olMailItem)
  18.   With itmMail
  19.     .To = ToList
  20.     .CC = CCList
  21.     .BCC = BCCList
  22.     .Subject = SubjectText
  23.     .BodyFormat = olFormatHTML
  24.     .HTMLBody = "<HTML><Head></Head><Body>"
  25.     .HTMLBody = .HTMLBody & "<table border=0 align=center><tr bgcolor=tomato><td align=center><font style=color:white;font-size:14pt;>This automated message is being sent to you by the Proprietary Document Central (PDC) website.<br>You will find important information and/or instructions below this announcement.</font></td></tr>"
  26.     .HTMLBody = .HTMLBody & "<tr bgcolor=OldLace><td><hr></td></tr>"
  27.     .HTMLBody = .HTMLBody & "<tr bgcolor=OldLace><td><font style=color:navy;font-size:12pt;>"
  28.  
  29.     .HTMLBody = .HTMLBody & "<tr bgcolor=OldLace><td><font style=color:navy;font-size:12pt;>" & MsgText & "</font></td></tr>"
  30.  
  31.     .HTMLBody = .HTMLBody & "<tr bgcolor=OldLace><td><hr></td></tr></table>"
  32.     .HTMLBody = .HTMLBody & "</body></html>"
  33.   End With
  34.  
  35.   If Method = "Send" Then
  36.     itmMail.Send
  37.   Else
  38.     itmMail.Display
  39.   End If
  40.  
  41.  
  42. End Function

I can automate Word to open the .RTF file and copy the contents...
VB Code:
  1. Dim oApp As New Word.Application
  2.   Dim oAbstractDoc As Word.Document
  3.   Dim oAbstractRange As Word.Range
  4.  
  5.     oApp.Visible = True
  6.     Set oAbstractDoc = oApp.Documents.Open(RTFFileName)
  7.     Set oAbstractRange = oAbstractDoc.Range
  8.     With oAbstractRange
  9.       .Select
  10.       .Copy
  11.     End With

...but then, how can I get the copied .RTF text pasted into the Outlook note?

I'm sorry if this went on too long, but I'd rather give too much instead of too little information. Many thanks for your help.

Zero_Duck