Subject: Problem Adding Disclaimer to Mail.box Design
See below, we have a central repository for keywords throught applications. We have two fields, the disclaimer and a tagline type thing, where we can put in things like ‘check out our website at…’, or voted #1 in…etc.
Just an FYI before I get to the code, I think I saw somewhere that a future release would have this built in. I don’t know if it is 6.5.4 or if they meant 7.0.
Below is the code that I put in on the postopen event:
Dim session As New NotesSession
Dim location As String
Dim localview As NotesView, view As NotesView
Dim localdoc As NotesDocument
Dim localdb As NotesDatabase, keyworddb As NotesDatabase, currentdb As NotesDatabase
Dim strServer As String, strFile As String
If source.IsNewDoc Then
If Left(source.FieldGetText("Subject"),2) = "Re" Then
Exit Sub
End If
If Left(source.FieldGetText("Subject"),2) = "Fw" Then
Exit Sub
End If
curloc=session.getenvironmentstring("Location", True)
For a=1 To Len(curloc)
tmpstring=Left(curloc,a)
If Right(tmpstring,1)="," Then useloc=Left(curloc,a-1)
If Right(tmpstring,1)="," Then
Exit For
End If
Next
Set localdb = New NotesDatabase( "", "names.nsf" )
Set localview = localdb.GetView("Locations")
Set localdoc = localview.GetDocumentByKey(useloc)
Set keyworddb = New NotesDatabase( localdoc.mailserver(0), "keywords.nsf" )
'Check to make sure we can connect to the keyword list
If keyworddb.IsOpen Then
Set view = keyworddb.GetView("AdminKeys")
Set doc = view.GetDocumentByKey("Email Tag Line")
Call source.FieldAppendText("Body",Chr(10))
Call source.FieldAppendText("Body",doc.AdminKeywords(0))
Call source.FieldSetText("TagLine",doc.AdminKeywords(0))
Set doc = view.GetDocumentByKey("Legal Statement")
Call source.FieldAppendText("Body",Chr(10))
Call source.FieldAppendText("Body",Chr(10))
Call source.FieldAppendText("Body",doc.AdminKeywords(0))
Call source.FieldSetText("LegalStatement",doc.AdminKeywords(0))
Else
Set currentdb = session.CurrentDatabase
Set view = currentdb.GetView("($Sent)")
Set doc = view.GetLastDocument
If doc Is Nothing Then
Else
Call source.FieldAppendText("Body",Chr(10))
Call source.FieldAppendText("Body",doc.TagLine(0))
Call source.FieldAppendText("Body",Chr(10))
Call source.FieldAppendText("Body",Chr(10))
Call source.FieldAppendText("Body",doc.LegalStatement(0))
End If
End If
End If