Incompatibility of Type - Lotus rich text item VBA

Emeric_H

New Member
Joined
Apr 13, 2015
Messages
1
Hi ,

I am trying to do a macro who read my email and especially the first Table of the body of my lotus notes email .

My Macro is based on the lotus documentation : Lotus Domino Designer 7 Help - LotusScript Classes A-Z
and especially this example who explain how to read a table Lotus Domino Designer 7 Help - Examples: NotesRichTextTable class


Here is my macro :

Code:
Public Sub Get_Notes_Email_Text()
    Dim NSession As Object      'NotesSession
    Dim NMailDb As Object       'NotesDatabase
    Dim NDocs As Object         'NotesDocumentCollection
    Dim NDoc As Object          'NotesDocument
    Dim NNextDoc As Object      'NotesDocument
    'Dim NItem As Object         'NotesItem
    Dim view As String
    Dim filterText As String
    
    view = "$All"       'Name of view or folder to retrieve documents from
    filterText = "test"     'Optional text string to filter the view
    
    Set NSession = CreateObject("Notes.NotesSession")
    Set NMailDb = NSession.GETDATABASE("", "")  'Default server and database
    If Not NMailDb.IsOpen Then
        NMailDb.OPENMAIL
    End If
    
    Set NDocs = NMailDb.GETVIEW(view)
    NDocs.Clear
    If filterText <> "" Then
        NDocs.FTSEARCH filterText, 0
    End If
    Set NDoc = NDocs.GETFIRSTDOCUMENT
    Do Until NDoc Is Nothing
        Set NNextDoc = NDocs.GETNEXTDOCUMENT(NDoc)
        Dim rti As NotesRichTextItem
        Set rti = NDoc.GetFirstItem("Body")
        If Not rti Is Nothing Then
            Dim rtnav As NotesRichTextNavigator
            Set rtnav = rti.CreateNavigator
            If Not rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
              MsgBox "Body item does not contain a table,", , _
              "Error"
              Exit Sub
            End If
            Dim rtt As NotesRichTextTable
            Set rtt = rtnav.GetElement
            Dim rtrange As NotesRichTextRange
            Set rtrange = rti.CreateRange
            Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
            firstFlag = True
            For i& = 1 To rtt.RowCount
              For j& = 1 To rtt.ColumnCount
                If Not firstFlag Then
                  Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
                Else
                  firstFlag = False
                End If
                Call rtrange.SetBegin(rtnav)
                MsgBox rtrange.TextParagraph, , _
                "Row " & i& & _
                ", Column " & j&
              Next
            Next
        End If
        Set NDoc = NNextDoc
    Loop
End Sub

I have got an error at the line "Set rti = NDoc.GetFirstItem("Body")" (Error 13 Incompatibility of type). I don't understant why the content of the email cannot be consider as a "Rich text" but only as a simple text . When i read the documentation the content of an email is supposed to be "rich text" . Is there a way to convert from simple text to rich text ?

Thanks for your help,
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Instead of declaring variables with the Lotus data types (e.g. NotesRichTextItem), try declaring them with the Object type, for example:
Code:
Dim rti As Object
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top