Variant Does Not Contain An Object for RTITEM

I KNOW this is easy, but I’m stuck.

I’m using a View Entry Collection to grab any docs in the ($Inbox) folder, then step through each and extract the attachment to a folder on a WinServer.

Just in the coding stages, and I can’t seem to get the rtitem to populate.

The error message is ‘Variant does not contain an object’. It’s right too. In debugger, RTITEM is empty.

Can someone please show me the error of my ways?

Thanks in advance for any help!

Here’s the code: (NOT COMPLETE - STILL NOT SET UP TO STEP THROUGH THE VIEW COLLECTION)

Sub Initialize

    Dim s As New NotesSession

    Dim db As NotesDatabase

    Set db = s.CurrentDatabase

    Dim view As NotesView

    Dim vc As NotesViewEntryCollection

    Set view = db.GetView("($Inbox)")

    Dim doc As NotesDocument

    Dim entry As NotesViewEntry

    Set vc = view.AllEntries

    Set entry = vc.GetFirstEntry()

    Dim rtitem As Variant

    Const MIN = 1

'…set value of doc…

    Set doc = entry.Document

    If ( rtitem.Type = RICHTEXT ) Then

            Forall o In rtitem.EmbeddedObjects

                    If ( o.Type = EMBED_ATTACHMENT ) And ( o.FileSize > MIN ) Then

                            Call o.ExtractFile ( "\\myserver\share\PDF_Documents\" & o.name )

                            Call o.Remove

                            Call doc.Save( True, True )

                            Call doc.PutInFolder("($Trash)")

                    End If

            End Forall

    End If

End Sub

Subject: Variant Does Not Contain An Object for RTITEM

You should use

dim rtitem as NotesRichTextItem

and

Set rtitem = doc.GetFirstItem(“Body”)

after doc is set.

Subject: RE: Variant Does Not Contain An Object for RTITEM

Doh.

Thanks, Niel. Worked like a charm.

Bruce