Examples: GetReceivedItemText method

This agent displays the text of the Received items in the current document. If the Received items are not in standard mail format, the error handler displays them with 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