Examples: TemplateName property

  1. This script gets the template name of DISCUSS4.NTF. The TemplateName property returns "StdR4Disc."
    Dim db As New NotesDatabase( "", "discuss4.ntf" )
    Dim template As String
    template = db.TemplateName
    Messagebox( template )
  2. Given a user name, server, and file name, this sub creates a new mail file for the user from the mail template. It uses the TemplateName property to find the StdR4Mail template.
    Sub createMailFile( user As String, server As String, _
    file As String )
      Dim templateDb As NotesDatabase
      Dim mailDb As NotesDatabase
      Dim directory As New NotesDbDirectory( server )
      Set templateDb = directory.GetFirstDatabase( TEMPLATE )
      While Not ( templateDb.TemplateName = "StdR4Mail" )
        Set templateDb = directory.GetNextDatabase
      Wend
      Call templateDb.Open( "", "" )
      Set mailDb = templateDb.CreateFromTemplate _
      ( server, "mail\"+file, True )
      mailDb.Title = user + " Mail"
      Call mailDb.GrantAccess( "Administrators", _
          ACLLEVEL_MANAGER )
      Call mailDb.GrantAccess( user, ACLLEVEL_EDITOR )
      If ( server <> "" ) Then
        Call mailDb.GrantAccess( server, ACLLEVEL_MANAGER )
      End If
    End Sub

    A sample call to this sub might look like this:

    Call createMailFile( "Brandon Herkle", "Pyongyang", _
      "brandon.nsf" )