Manage Learn to apply best practices and optimize your operations.

Populate group Internet addresses

Do you have a lot of groups in your NAB, or users who want to send mail to these groups from outside your Notes Domain?

Do you have a lot of groups in your NAB? Do you have users who would like to send Internet mail to these groups from outside your Notes Domain? We did but had a slight problem. We had group names with spaces, which does not work well with Internet Mail. Also, we had thousands of groups and to manually populate the R5 Internet Address Field for all of our groups would take forever. So, I wrote some code that would handle it for us. The code is not very difficult really, just very monotonous. Here is what the code will do:

1. Look at the group document and get the name of the group.
2. Try to create an Internet Address for the group using the name.
3. If the name contains spaces then it will use an Internet standard for the naming convention.
4. The code can handle a group name with up to 6 spaces in it.
5. The naming convention for the Internet address is as follows:

No spaces
Group Name: SteveHolman
Internet Address:

1 Space
Group Name: Steve Holman
Internet Address:

2 Spaces
Group Name: Steve Ray Holman
Internet Address:

3 spaces
Group Name: Steve Ray Holman Jr
Internet Address:

etc. Basically the last word will have a "." dot in front of it and any preceding spaces will be replaced by "_" underscores. This allows for a SMTP RFC Standard Internet mail address.

Code modifications you will need to make:

1. Change the domain variable in the code to equal your domain name in the format ""
2. Change the line that reads Set db = session.GetDatabase("DOMHUB1","names.nsf") to have your server name rather than "DOMHUB1".
3. The agent is set to run manually from the agent list, you can set it to run scheduled but will need to change the same line from "DOMHUB1" to "".
4. We put the agent in the NAB itself, but you can put it anywhere on the server.


Steve Holman
Wachovia Bank, NA

'Program Name: PopulateGroupInternetAddresses
'Date: 09/17/2001
'Coded By: Steve Holman
'File Name: appsopsmassmail.nsf
'Program Description: This code will set all groups in the NAB with a valid Internet Address.
'Development Environment: R5 Designer


Sub Initialize
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim item As NotesItem
	Dim grpname As NotesItem
	Dim itemtext As String
	Dim grpnametext As String
	Dim substring As String
	Dim substring2 As String
	Dim substring3 As String
	Dim substring4 As String
	Dim substring5 As String
	Dim substring6 As String
	Dim fname As String
	Dim mi As String
	Dim mi2 As String
	Dim mi3 As String
	Dim mi4 As String
	Dim mi5 As String
	Dim domain As String
	Dim pos As Integer
	Dim length As Integer
	Dim pos2 As Integer
	Dim pos3 As Integer
	Dim pos4 As Integer
	Dim pos5 As Integer
	Dim pos6 As Integer
	Dim pos7 As Integer
	Dim pos8 As Integer
	Dim pos9 As Integer
	Dim pos10 As Integer
	Dim pos11 As Integer
	Dim pos12 As Integer
	Dim length2 As Integer
	Dim length3 As Integer
	Dim length4 As Integer
	Dim length5 As Integer
	Dim length6 As Integer
	domain = ""
	Set db = session.GetDatabase("DOMHUB1","names.nsf")
	Set view = db.GetView("Groups")
	Set doc = view.GetFirstDocument
	Do While Not(doc Is Nothing)
		Set item = doc.GetFirstItem("InternetAddress")
		If Not(item Is Nothing) Then
			itemtext = item.Text
		End If
		If itemtext = "" Then
			Set grpname = doc.GetFirstItem("ListName")
			grpnametext = grpname.Text
			length = Len(grpnametext)
			pos = Instr(1,grpnametext," ")
			If pos = 0 Then
				Set item = doc.ReplaceItemValue("InternetAddress", grpnametext + domain)
				pos2 = length - pos
				substring = Right(grpnametext,pos2)
				fname = Left(grpnametext, pos -1)
				pos3 = Instr(1,substring," ")
				If pos3 = 0 Then
					Set item = doc.ReplaceItemValue("InternetAddress", 
fname + "." + substring + domain) Else length2 = Len(substring) pos4 = length2 - pos3 substring2 = Right(substring, pos4) mi = Left(substring, pos3 -1) pos5 = Instr(1,substring2," ") If pos5 = 0 Then Set item = doc.ReplaceItemValue("InternetAddress",
fname + "_" + mi + "." + substring2 + domain) Else length3 = Len(substring2) pos6 = length3 - pos5 substring3 = Right(substring2, pos6) mi2 = Left(substring2, pos5 -1) pos7 = Instr(1,substring3, " ") If pos7 = 0 Then Set item = doc.ReplaceItemValue("InternetAddress",
fname + "_" + mi + "_" + mi2 + "." +
substring3 + domain) Else length4 = Len(substring3) pos8 = length4 - pos7 substring4 = Right(substring3, pos8) mi3 = Left(substring3, pos7 -1) pos9 = Instr(1,substring4," ") If pos9 = 0 Then Set item = doc.ReplaceItemValue("InternetAddress",
fname + "_" + mi + "_" + mi2 + "_" + mi3 + "." +
substring4 + domain) Else length5 = Len(substring4) pos10 = length5 - pos9 substring5 = Right(substring4, pos10) mi4 = Left(substring4, pos9 - 1) pos11 = Instr(1,substring5," ") If pos11 = 0 Then Set item = doc.ReplaceItemValue("InternetAddress",
fname + "_" + mi + "_" + mi2 + "_" + mi3 + "_" +
mi4 + "." + substring5 + domain) Else length6 = Len(substring5) pos12 = length6 - pos11 substring6 = Right(substring5, pos12) mi5 = Left(substring5, pos11 - 1) Set item = doc.ReplaceItemValue("InternetAddress",
fname + "_" + mi + "_" + mi2 + "_" + mi3 + "_" + mi4 + "_" +
mi5 + "." + substring6 + domain) End If End If End If End If End If End If End If pos = 0 pos2 = 0 pos3 = 0 pos4 = 0 pos5 = 0 pos6 = 0 pos7 = 0 pos8 = 0 pos9 = 0 pos10 = 0 pos11 = 0 pos12 = 0 length = 0 length2 = 0 length3 = 0 length4 = 0 length5 = 0 length6 = 0 itemtext = "" Call doc.Save(True,True) Set doc = view.GetNextDocument(doc) Loop End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.



  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...