Hallo Leute,
Kann mir jemand helfen, warum der agent nicht tut, was er tun soll.
Er soll in der DB aus dem Namensfeld “Mailadress“, in dem der User die gewüschte Weiterleitungsadresse einträgt, den Wert holen und im domino verzeichnis nach dem User suchen, der sich angemeldet hat und in seinem personen dokument in das Feld „Mailadress“
diese Adresse eintragen. Hat jemand vielleicht eine Idee??
Danke für die Hilfe
Gruß Jack
Sub Initialize
' code by Bob Pratico of K2ITS
' version 2.6 (02/11/02)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim j As Integer
Dim str_array As Variant
Dim ChosenUsername As String
Dim Mailadress As String
Dim num_docs As Integer
Dim dateTime As New NotesDateTime("1/1/97")
Dim aLog As New NotesLog("Agent log")
Call aLog.OpenAgentLog
On Error Goto ErrorHandler
Set doc = session.DocumentContext
Set db = session.CurrentDatabase
Call aLog.LogAction("Agent executing by " & doc.NotesUserNameDisplayed(0))
Dim NamesDb As New NotesDatabase("", "NAMES.nsf")
Dim FoundList As NotesDocumentCollection
Dim NameDoc
Dim eval As Variant
str_array = doc.GetItemValue("NotesUserName")
ChosenUsername = str_array(0)
str_array = doc.GetItemValue("Mailadress")
Mailadress = str_array(0)
' Search all the NABs on this server for a
' document that contains the ChosenUsername in
' the FullName field. Then you need to set the
' HTTPassword field in this document to the
' ChosenPassword value. Finally save this document
' in the Name and Address Book. At this time you can
' also delete the document in the SetPassword database
' that triggered this change. Otherwise every time the
' agent ran, it would just set the password over and over again.
' Set FoundList = NamesDb.Search("ShortName = """ + ChosenUsername + """", dateTime, 0)
Dim books As Variant
Dim view As NotesView
Dim done As Variant
books = session.AddressBooks
done = False
Forall b In books
' check every Domino Directory, unless we're already done
If ( b.IsPublicAddressBook ) And ( Not done ) Then
On Error Resume Next
Call b.Open( "", "" )
' look up server's last name in Servers view of address book
Set FoundList = b.Search("FullName = """ + ChosenUsername + """", dateTime, 0)
If FoundList.count > 0 Then
Set NameDoc = FoundList.GetNthDocument(1)
Messagebox ChosenPassword
NameDoc.MailAddress= ChosenPassword
Call Namedoc.save(True,False)
Messagebox Namedoc.fullname(0)
' Use @Password formula code to scramble the new password value.
' Use LotusScript Evaluate function to execute the formula statement
' in LotusScript.
' Call NameDoc.Save(False, False)
' done = True
Dim flag As Boolean
flag = NameDoc.Save(True,False)
' Print "flag = " & flag
If flag = False Then
Print "<br><br><b><h3> Für diese Aktion sind Sie nicht berechtigt.</H3>"
done = True
Else
Print "<br><br> <b><h3>" + doc.NotesUserNameDisplayed(0) +", Die Weiterlungadresse ist eingetragen.</H3>"
done = True
End If
NextAddressBook:
Exit Forall
End If
End If
End Forall
' if done is still False, the user wasn't found in any Address Book
If Not done Then
Print "Sorry - Ihr Name wurde im Adressbuch auf diesem Server nicht gefunden."
End If
'doc.Remove(True)
Call aLog.Close
Exit Sub
ErrorHandler:
Dim ErrString As String
ErrString="INITIALIZE : Script Error on Line : " + Cstr(Erl()) + Chr(10)+Chr(10)+"Error Message : " + Error$
'Print doc.ErrorFieldErrString
Call aLog.LogAction(ErrString)
Call aLog.Close
Exit Sub
End Sub