Examples: GetElement method

This agent displays the file path and title of the target database of the first or only doclink in the Body item of the current or first selected document.

Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim rtlink As NotesRichTextDocLink
Sub Initialize
  Set session = New NotesSession
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  Set rti = doc.GetFirstItem("Body")
  Set rtnav = rti.CreateNavigator
  If Not rtnav.FindFirstElement(RTELEM_TYPE_DOCLINK) Then
    Messagebox "No doclinks in Body item",, "No doclinks"
    Exit Sub
  End If
  Set rtlink = rtnav.GetElement
  Dim linkDb As New NotesDatabase("", "")
  If linkDb.OpenByReplicaID("", rtlink.DbReplicaID) Then
    Messagebox linkDb.FilePath,, """" & linkDb.Title & """"
  Else
    Messagebox "No local replica",, "Cannot find database"
  End If
End Sub