Das Notes Forum
Domino 9 und frühere Versionen => Administration & Userprobleme => Thema gestartet von: ajo am 29.08.02 - 14:29:29
-
Hallo zusammen !
Kennt jemand eine Möglichkeit, die Internet Mail-Adresse im Arbeitsumgebungsdokument automatisch anzupassen ? Wir müssten diese bei ca. 700 Clients ändern und möchten ungern Makros durch die User ausführen lassen.
Danke
ajo
-
Ich verwende für solche zwecke ein Script in der Maildatei.
Das Script holt sich aus dem NAB die "richtige" Internetadresse ( und noch einiges mehr ) und schreibt es in das AUDoc des DAU.
Das Script wird beim Öffnen der Datenbank ausgeführt
Hier die Funktion:
Function UpdateUsersLocationDocument()
Dim viewLocations As NotesView
Dim viewPeople As NotesView
Dim docLocation As NotesDocument
Dim docPerson As NotesDocument
Dim dbNAB As NotesDatabase
Dim dbPAB As NotesDatabase
Dim LocationDocument As String
Dim nnUserName As NotesName
Dim PersonalAddressBook As String
Dim MailFile As String
Dim MailFilePerson As String
'Get the personal address book from the notes.ini and remove any cascaded local address books
PersonalAddressBook = Trim(session.GetEnvironmentString("Names",True))
If Instr(PersonalAddressBook, ",") > 0 Then
PersonalAddressBook = Left$(PersonalAddressBook, Instr(PersonalAddressBook, ",") -1)
Else
If Instr(PersonalAddressBook, ";") > 0 Then
PersonalAddressBook = Left$(PersonalAddressBook, Instr(PersonalAddressBook, ";") -1)
End If
End If
'Get the personal address book, exit if cannot be opened
Set dbPAB = session.GetDatabase("", PersonalAddressBook)
If dbPAB.IsOpen = False Then Goto FinishFunction
'Get the current location document in use, exit if any errors
Set viewLocations = dbPAB.GetView("Locations")
If viewLocations Is Nothing Then Goto FinishFunction
LocationDocument = Trim(session.GetEnvironmentString("Location",True))
If LocationDocument = "" Then Goto FinishFunction
LocationDocument = Left$(LocationDocument, Instr(LocationDocument, ",") -1)
If LocationDocument = "" Then Goto FinishFunction
Set docLocation = viewLocations.GetDocumentByKey(LocationDocument)
If docLocation Is Nothing Then Goto FinishFunction
'Get the Public Address Book from the current server
Set dbNAB = session.GetDatabase(dbCurrent.Server, "names.nsf")
If dbNAB.IsOpen = False Then Goto FinishFunction
'Get the current users person document. Exit if user not in address book
Set viewPeople = dbNAB.GetView("($VIMPeople)")
Set nnUserName = New NotesName(session.UserName)
Set docPerson = viewPeople.GetDocumentByKey(nnUserName.Abbreviated)
If docPerson Is Nothing Then Goto FinishFunction
'Get the name of the mail file from the person document and current database
MailFile = dbCurrent.FilePath
MailFilePerson = docPerson.MailFile(0)
If Lcase(Right$(MailFilePerson, 4)) <> ".nsf" Then
MailFilePerson = MailFilePerson & ".nsf"
End If
'Update the Location Document, if the mail file name in the address book matches the name of the current database
If Lcase(MailFile) <> Lcase(MailFilePerson) Then Goto FinishFunction
docLocation.MailFile = MailFile
docLocation.MailServer = docPerson.MailServer(0)
docLocation.DirectoryServer = docPerson.MailServer(0)
docLocation.CatalogServer = docPerson.MailServer(0)
docLocation.Domain = docPerson.MailDomain(0)
docLocation.ImailAddress = docPerson.InternetAddress(0)
Call docLocation.Save(True, False)
Call session.SetEnvironmentVar("DateLocationModified", sDateTime, False)
FinishFunction:
End Function
eknori
-
Hallo !
Erstmal danke für die sensationell schnelle Antwort auf mein Anliegen ;-)
Wenn du mir jetzt noch erklären kannst wie ich das anstelle, das dieses Script beim öffnen der Mail-DB ausgeführt wird.....
mercy
ajo
-
Kopiere die Funktion ( eigentlich muss es heissen Sub ) in das DatenbankScript der Mailschablone.
In den PostOpen Event des Datenbank Scripts trägst du ein Call Update.....
Dann die Datenbankgestaltung aktualisieren und nach der Aktualisierung die DB öffnen.
That's all
eknori
-
Hat mit kleinen Anpassungen des Scripts einwandfrei funktioniert. Vielen Dank
Gruß
ajo
Function UpdateUsersLocationDocument()
Dim session As New NotesSession
Dim viewLocations As NotesView
Dim viewPeople As NotesView
Dim docLocation As NotesDocument
Dim docPerson As NotesDocument
Dim dbNAB As NotesDatabase
Dim dbPAB As NotesDatabase
Dim LocationDocument As String
Dim nnUserName As NotesName
Dim PersonalAddressBook As String
Dim MailFile As String
Dim MailFilePerson As String
Dim dbCurrent As NotesDatabase
Set dbCurrent = session.CurrentDatabase
Dim DateTimeNow As NotesDateTime
Set DateTimeNow = New NotesDateTime(Now)
Dim sDateTime As String
sDateTime = DateTimeNow.LsLocalTime
'Get the personal address book from the notes.ini and remove any cascaded local address books
PersonalAddressBook = Trim(session.GetEnvironmentString("Names",True))
If Instr(PersonalAddressBook, ",") > 0 Then
PersonalAddressBook = Left$(PersonalAddressBook, Instr(PersonalAddressBook, ",") -1)
Else
If Instr(PersonalAddressBook, ";") > 0 Then
PersonalAddressBook = Left$(PersonalAddressBook, Instr(PersonalAddressBook, ";") -1)
End If
End If
'Get the personal address book, exit if cannot be opened
Set dbPAB = session.GetDatabase("", PersonalAddressBook)
'Set dbPAB = session.GetDatabase("", "names.nsf")
If dbPAB.IsOpen = False Then Goto FinishFunction
'Get the current location document in use, exit if any errors
Set viewLocations = dbPAB.GetView("Locations")
If viewLocations Is Nothing Then Goto FinishFunction
LocationDocument = Trim(session.GetEnvironmentString("Location",True))
If LocationDocument = "" Then Goto FinishFunction
LocationDocument = Left$(LocationDocument, Instr(LocationDocument, ",") -1)
If LocationDocument = "" Then Goto FinishFunction
Set docLocation = viewLocations.GetDocumentByKey(LocationDocument)
If docLocation Is Nothing Then Goto FinishFunction
'Get the Public Address Book from the current server
Set dbNAB = session.GetDatabase(dbCurrent.Server, "names.nsf")
If dbNAB.IsOpen = False Then Goto FinishFunction
'Get the current users person document. Exit if user not in address book
Set viewPeople = dbNAB.GetView("($VIMPeople)")
Set nnUserName = New NotesName(session.UserName)
Set docPerson = viewPeople.GetDocumentByKey(nnUserName.Abbreviated)
If docPerson Is Nothing Then Goto FinishFunction
'Get the name of the mail file from the person document and current database
MailFile = dbCurrent.FilePath
MailFilePerson = docPerson.MailFile(0)
If Lcase(Right$(MailFilePerson, 4)) <> ".nsf" Then
MailFilePerson = MailFilePerson & ".nsf"
End If
'Update the Location Document, if the mail file name in the address book matches the name of the current database
If Lcase(MailFile) <> Lcase(MailFilePerson) Then Goto FinishFunction
docLocation.MailFile = MailFile
docLocation.MailServer = docPerson.MailServer(0)
docLocation.DirectoryServer = docPerson.MailServer(0)
docLocation.CatalogServer = docPerson.MailServer(0)
docLocation.Domain = docPerson.MailDomain(0)
docLocation.ImailAddress = docPerson.InternetAddress(0)
Call docLocation.Save(True, False)
Call session.SetEnvironmentVar("DateLocationModified", sDateTime, False)
FinishFunction:
End Function
-
Wie kann ich das als Button in einer eMail verwenden?
Gruss
Martin
-
Wo speziell hast Du denn ein Problem ?
Bernhard
-
Wenn`s um den Button selbst geht (obwohl ich mir das eigentlich nicht vorstellen kann):
In der neuen Mail Erstellen->Hotspot->Schaltfläche, dann von Formel auf LotusScript umstellen und den Code reinpacken.
HTH
Thomas
-
... und dann beten, dass kein User die Mail öffnet, wenn er nach der Replikation das Mailfile lokal öffnet ... Das ist nämlich eine eklatante Schwäche des geposteten Codes (der aber andererseits davon ausgeht, dass das PersNAB anders als NAMES.NSF heissen könnte ... Und dieses Problem hat nichts damit zu tun, ob der Code im DatabaseScript oder in einem Buhting steckt.
Bernhard
-
Wir haben alle unsere Internet Domains vereinheitlicht und nun hat es Benutzer die immer noch die alten absender verwenden. Deshalb möchte ich nen Knopf verschicken, der die Arbeistumgebung umstellt anhand der Mailadress im Addressbuch.
Gruss
Martin
-
Wann werden die Änderungen in der AU aktiv?
Ich ändere über ein ähnliches Script wie eknori und ajo einen Wert in der aktuellen AU.
Damit diese Änderung aktiv wird, muss Notes zuerst schließen und neu starten.
Kann diese Änderung auch ohne Notes zu schließen aktiv gemacht werden? evtl über Script Befehl?
-
Kann diese Änderung auch ohne Notes zu schließen aktiv gemacht werden? evtl über Script Befehl?
Nein. Aus Performance-Gründen werden die AU-Dokumente beim Wechsel der AU ausgelesen oder bestenfalls bei Änderungen über das Frontend auf den neuesten Stand (intern) gebracht. Und wenn Du via LS / @Commands die AU hin- und herwechselst, handelst Du Dir programmtechnisch eher mehr Aufwand und Probleme ein, als wenn Du zum Schliessen des Clients aufforderst oder das programmtechnisch erzwingst.
Bernhard
PS: Da man AU-Dokumente nicht alle zwei Stunden programmatisch ändert - wo ist das eigentliche Problem?
-
Sorry das ich nicht geantwortet haben, doch ich war jetzt längere Zeit im Urlaub ;D.
Mein Problem hat sich soweit auch schon erledigt. Ich erstelle einfach eine neue AU und kopiere die Daten der aktuellen in diese rein. Danach ändere ich die benötigten Werte in der aktuellen AU und wechsle danach in die neu erstellte AU. Danach wechsle ich sofort wieder zurück. Nun sind die Änderungen, die ich vor dem Wechsel gemacht habe sofort aktiv ohne Neustart von Notes usw.... Die neu erstellte AU lösche ich wieder.
Gruß hupfi