Hi!
I am still fighting with outlook myappointment.RTFBODY method...
I have found on some page that there is a workround which will give me a possibility to put there html text...
I have tried it, and it wokrs - almost...

webBrowser.CreateControl(); 
webBrowser.DocumentText = html; // HTML = HTML CODE
Application.DoEvents();
webBrowser.Document.ExecCommand("SelectAll", false, null);
webBrowser.Document.ExecCommand("Copy", false, null);
RichTextBox testbox = new RichTextBox();
testbox.Paste(); // PROBLEM LIES HERE

The problem is that .Paste() method paste everything without formating (no colors, pictures - just text + tables)
I need use "paste while maintaining formatting" which is available in every M$ prog..
Still. I dont know how to do that in C#

Please help!

Recommended Answers

All 4 Replies

try using this code:

    testBox.Text = Clipboard.GetText(TextDataFormat.Rtf);

Will check it after work - thx!

Unfortnuanetly problem is still there. I have modified the code:

testBox.Rtf = Clipboard.GetText(TextDataFormat.Rtf);

The result is the same...Text is pasted in, tables are pasted in, but no colors and pictures.

The funniest thing is that content is stillin clipboard..So if i enter (for ex.) Word, and press CTRL+V...Everything is pasted in correctly :(..

Still dunno how to do that in C#

I have found out that I need to use WORD inspector in order to copy mail.Body to appointment.Body
I have the code which will do that , but its in VB :(
Can you help me how to do that in c#?

Sub CopyFullBody(sourceItem As Object, targetItem As Object)
    Dim objDoc As Word.Document
    Dim objSel As Word.Selection
    Dim objDoc2 As Word.Document
    Dim objSel2 As Word.Selection
    On Error Resume Next
    ' get a Word.Selection from the source item
    Set objDoc = sourceItem.GetInspector.WordEditor
    If Not objDoc Is Nothing Then
        Set objSel = objDoc.Windows(1).Selection
        objSel.WholeStory
        objSel.Copy
        Set objDoc2 = targetItem.GetInspector.WordEditor
        If Not objDoc2 Is Nothing Then
            Set objSel2 = objDoc2.Windows(1).Selection
            objSel2.PasteAndFormat wdPasteDefault
        Else
            MsgBox "Could not get Word.Document for " & _
                   targetItem.Subject
        End If
    Else
        MsgBox "Could not get Word.Document for " & _
               sourceItem.Subject
    End If
    Set objDoc = Nothing
    Set objSel = Nothing
    Set objDoc2 = Nothing
    Set objSel2 = Nothing
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.