Subject: RE: Create mail databases for 300 users
Here is the agent, but I would have to give the disclaimer to use at your risk. I can not be liable for anything you are not understand prior to running the agent. I urge you to test this via the debugger before you do this for all the users in the address book.
With the lawyers satified here is the code:
Dim namesdb As NotesDatabase, maildb As notesdatabase, mailntf As NotesDatabase, ntitem As NotesItem
Dim PeopleVw As Notesview, persondoc As Notesdocument, nameitem As Notesname
Dim mailprofile As NotesDocument, personcollection As NotesDocumentCollection
Dim session As New NotesSession, acl As NotesACL, aclentry As NotesACLEntry
Dim filename As String, NotesDomain As String, InternetDomainSuffix As String
Set mailntf = New NotesDatabase(session.CurrentDatabase.Server, “mail6.ntf”)
Set namesdb = New Notesdatabase(Session.CurrentDatabase.Server, “names.nsf”)
Set PeopleVw = namesdb.GetView(“Mail Users”)
Set personcollection = PeopleVw.GetAllDocumentsByKey(“* No mail file specified”) ’ These are the person documents which do not have a Mail Server specifed
Set persondoc = personcollection.getfirstdocument
NotesDomain = “Domain” ’ You need to put in your domain you configured for the domino mail environment
InternetDomainSuffix = “@Domain.com” ’ You need to put your internet suffix the part on the right side of the @
While Not (persondoc Is Nothing)
'Check to see if the person has a mail file already 100 text value means NONE
If persondoc.MailSystem(0) = “100” Then
Set nameitem = Session.CreateName(persondoc.FullName(0) )
filename = Lcase(|mail| & persondoc.FirstName(0) & persondoc.LastName(0) & |.nsf| )
Set maildb = mailntf.createfromtemplate(Session.CurrentDatabase.Server, filename, True)
maildb.title = nameitem.Common
Set acl = maildb.ACL
Set aclentry = New NotesACLEntry ( acl, nameitem.Canonical, ACLLEVEL_MANAGER)
’ Now you have to set up the calendar profile for the person
Set mailprofile = maildb.GetProfileDocument(“CalendarProfile”)
mailprofile.Owner = nameitem.Canonical
Call mailprofile.save(True,False,True)
’ Now to update the preson document to point to the newly created mail file.
persondoc.MailSystem = “1” ’ Notes mail
persondoc.MailDomain = NotesDomain
persondoc.MailServer = namesdb.Server
persondoc.MailFile = filename
’ this script assumes you want the common name as part of the internet address
’ E.G John Q Public/Org will have an internet address of johnpublic@domain.com
persondoc.InternetAddress = Lcase(persondoc.FirstName(0) & persondoc.LastName(0) & internetdomainsuffix)
Call persondoc.Save(True,True,True)
'Finished with the creation for this document
End If
Set persondoc = personcollection.getnextdocument(persondoc)
Wend
Messagebox (“Script Done”)
The possible error you could get is if the mailfile already exist but the person document was never updated. Be sure to put in your Notes domain and your internet domain for the email address.
HTH – Cheers