例: GetReceivedItemText method

次のエージェントは、現在の文書の Received アイテムのテキストを表示します。Received アイテムが標準のメールフォーマットになっていない場合は、エラー処理プログラムが GetItemValue を使用してそのアイテムを表示します。

Sub Initialize
  On Error Goto errh
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim count As Integer
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument()
  receivedItemText = doc.GetReceivedItemText()
  If receivedItemText(0) = "" Then
    Messagebox "No Received items in document",, "No Received items"
  Else
    count = 0
    Forall received In receivedItemText
      count = count + 1
      Messagebox received,, "Received item " & count
    End Forall
  End If
  Exit Sub
errh:
  Messagebox Error(),, "Error # " & Err()
  If Err() = lsERR_NOTES_INVALID_RECEIVEDITEM Then
    receivedItemText = doc.GetItemValue("Received")
    count = 0
    Forall received In receivedItemText
      count = count + 1
      Messagebox received,, "Received item " & count
    End Forall
  End If
  Exit Sub
End Sub