Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save RichTextBox text in outlook body

Status
Not open for further replies.

TysonLPrice

Programmer
Jan 8, 2003
859
US
I'm trying to save the text of a RichTextBox to the body of an OutLook Express Email and I keep losing the formating. I have tried a couple of things with the following being the last failure. Does anyone have something to do this or see why this doesn't work?

The text box is formatted at this point:

Code:
Dim MyOlApp As New Outlook.Application
    Dim MyItem As Outlook.MailItem
    Set MyOlApp = CreateObject("Outlook.Application")
    Set MyItem = MyOlApp.CreateItem(olMailItem)
    MyItem.To = "BlahBlah@Blah.com"
    MyItem.Subject = "Outlook test"
    
     With rtfTextEmailBody
        Clipboard.Clear
        .SelStart = "0"
        .SelLength = Len(.Text)
        .SetFocus
         SendKeys "^c", True
         Me.Hide
         MyItem.Display
         SendKeys "^v", True
    End With
    
    MyItem.Send
    Set MyItem = Nothing
    Set MyOlApp = Nothing
 
You mention that you've already tried a couple of things, so perhaps it's not really useful what I suggest, but in my environment the following works:

Code:
    Dim MyOlApp As New Outlook.Application
    Dim MyItem As Outlook.MailItem
    Set MyOlApp = CreateObject("Outlook.Application")
    Set MyItem = MyOlApp.CreateItem(olMailItem)
    MyItem.To = "andreas.grob@dataserv.ch"
    MyItem.Subject = "Outlook test"
    MyItem.Display
    ActiveInspector.Activate
    MyItem.Body = rtfTextEmailBody.TextRTF
    MyItem.Send
    Set MyItem = Nothing
    Set MyOlApp = Nothing
 
Thanks for the response. I ran that exactly as posted and it puts the mark up tags in the Email. Like this:

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}
{\colortbl ;\red255\green0\blue0;}
\viewkind4\uc1\pard\li1005\lang1033\f0\fs17 Th\cf1 IS \cf0 is a test
\par }

Did it work for you as posted? I'm using Outlook 2000.

I ended up writing the Email report using HTML but would still like to see the RTB option work.
 
Yes, it ran exactly like this. Perhaps it's a matter of the message format which I've set to Rich Text for the Test, where I've normaly set it to Text only.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top