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
If rtlink.DocUNID = String$(32, "0") Then
Messagebox "Link does not have a doc component",, _
"No doc"
Exit Sub
End If
Dim linkDb As New NotesDatabase("", "")
If Not linkDb.OpenByReplicaID("", _
rtlink.DbReplicaID) Then
Messagebox "No local replica",, "Cannot find database"
Exit Sub
End If
Dim linkDoc As NotesDocument
On Error Goto InvalidUNID
Set linkDoc = linkDb.GetDocumentByUNID(rtlink.DocUNID)
Messagebox linkDoc.Subject(0),, "Subject of document"
Exit Sub
InvalidUNID:
Messagebox "Cannot locate document",, "No document"
Exit Sub
End Sub