Examples: GetFirstItem method

  1. This script prints a message about the Subject item in a document.
    Dim doc As NotesDocument
    '...set value of doc...
    Dim item As NotesItem
    Set item = doc.GetFirstItem( "Subject" )
    If ( item Is Nothing ) Then
      Messagebox( "No Subject item on the document." )
    Else
      Messagebox(  _
      "The Subject item on the document has the value: " _
      + item.Text )
    End If
  2. This example demonstrates an attempt to get the value of the DateComposed item in a document. If there is no such item (possibly because DateComposed is only a field that's computed for display), it uses the Created property instead.
    Dim doc As NotesDocument
    Dim item As NotesItem
    Dim dateTime As New NotesDateTime( "" )
    '...set value of doc...
    Set item = doc.GetFirstItem( "DateComposed" )
    ' An item called DateComposed doesn't exist on the document
    If ( item Is Nothing ) Then
      dateTime.LSLocalTime = doc.Created
    ' an item called DateComposed exists 
    ' on the document
    Else
      Set dateTime = item.DateTimeValue
    End If
  3. This script gets a rich text item from a document and adds some text to it.

    Dim doc As NotesDocument
    Dim rtitem As NotesRichTextItem
    '...set value of doc...
    Set rtitem = doc.GetFirstItem( "Body" )
    If ( rtitem.Type = RICHTEXT ) Then
      Call rtitem.AppendText( "One line of text" )
      Call rtitem.AddNewLine( 2 )
      Call rtitem.AppendText( "Another line of text" )
      Call doc.Save( False, True )
    End If