
ADDRESS BOOK
Change Mailserver For A 'Group' Of Users
Wil Conway 05.12.2000
Rating: --- (out of 5)




This code allows you to change the mailserver for all users listed in a group. It could easily be modified to change any field in a person document.
Code
Sub Initialize On Error Goto Error_Handler '=============================================================================== ======== ' AGENT INTRODUCTION '=============================================================================== ======== Continue = Msgbox ("This agent will change the mailserver entries for all users in a group" & Chr(13) _ & "that you specify with the server that you specify." & Chr(13) _ & "Do you still wish to continue?",68,"'Change Mailserver for a Group of Users' Agent") If Continue = 7 Then Exit Sub End If '=============================================================================== ======== ' DECLARATIONS '=============================================================================== ======== Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim Groupdoc As NotesDocument Dim Persondoc As NotesDocument Dim myServerName As String Dim myGroupName As String Dim mycounter As Integer '=============================================================================== ======== ' USER INPUT 'GROUP' '=============================================================================== ======== Enter_Group: myGroupName = Inputbox ("What is the name of the group that has the users you would like to convert?" _ , "Input Required") '=============================================================================== ======== ' INPUT VALIDATION 'GROUP' '=============================================================================== ======== If myGroupName = "" Then Exit Sub End If Set db = Sessio
To continue reading for free, register below or login
To read more you must become a member of SearchDomino.com
');
// -->

n.CurrentDatabase Set view = db.getview("Groups") 'Get group view Set Groupdoc = view.getdocumentbykey(myGroupName,True) ' Get group doc If (Groupdoc Is Nothing) Then Msgbox "This is not a valid group. Please try again!", 16 ,"PROBLEM:" Goto Enter_Group End If '=============================================================================== ======== ' USER INPUT 'SERVER' '=============================================================================== ======== Enter_Server: myServerName = Inputbox ("What is the name of the server that you would like to set these users to?" _ & Chr(13) & "Note: the server name must be canonicle", "Input Required", _ "CN=YourCN/OU=YourOU/O=YourO") '=============================================================================== ======== ' INPUT VALIDATION 'SERVER' '=============================================================================== ======== If myServerName = "" Then Exit Sub Else If Not (myServerName Like "CN=*" And _ myServerName Like "*OU=*" And _ myServerName Like "*O=*") Then Msgbox "You did not enter the Server Name in the correct format!", 16 ,"PROBLEM:" Goto Enter_Server End If End If '=============================================================================== ======== ' USER INPUT CHECK '=============================================================================== ======== Continue = Msgbox ("You are about to change the mailserver entry to " & Chr(13) _ & myServerName & Chr(13) _ & "for all users in the " & "'" & myGroupName & "'" & " group." & Chr(13) _ & "Do you still wish to continue?",36,"'Change Mailserver for a Group of Users' Agent") If Continue = 7 Then Exit Sub End If '=============================================================================== ======== ' MAIN CODE '=============================================================================== ======== Set view = db.getview("($Users)") ' Get user view Forall x In Groupdoc.members Set Persondoc = view.getdocumentbykey(x,True) ' Get user doc If Not(Persondoc Is Nothing) Then Persondoc.mailserver = myServerName 'Set new MailServer value Call Persondoc.save (True,True) 'Save doc Print "Modifying Person Doc For: " & x <WHATL
 |

|
|
 |
|
 |