I am trying to create a button to email out to my users that will chnage their email address in all their location docs from user@OldDomain.com to user @NewDomain.com
Not being very familiar with lotusscript I found some code and adapted it but it just doesn’t make the change - though it is running as it comes up with the final message box. Please can anyone help me to see what is wrong? Many thanks Anne
THis is the code
Sub Click(Source As Button)
Dim s As New NotesSession
Dim view As NotesView
Dim doc As NotesDocument
Dim newDomain As String
Dim oldDomain As String
Dim toNotify As String
toNotify = "anne"
newDomain = "@olddomain.com"
oldDomain = "@newdomainx.com"
sNamesLine=s.GetEnvironmentString("NAMES", True)
nPos = Instr(sNamesLine, ",")
sNamesLine = "names.nsf"
Set db = New NotesDatabase( "",sNamesLine )
If Not(db.isOpen) Then
Messagebox "Attention: Address book not found. Please, contact the Help Desk."
Exit Sub
End If
Set view = db.GetView("Locations")
Dim email, domain, predomain As String
Dim message As String
message = ""
Set doc = view.GetFirstDocument
While Not doc Is Nothing
If doc.HasItem("ImailAddress") Then
email=doc.ImailAddress(0)
domain = Strtoken(email, "@", 2)
If domain = oldDomain Then
predomain = Strtoken(email, "@", 1)
email = predomain + newDomain
message = message + " Location updated: " + doc.Name(0) + Chr(10)
Call doc.ReplaceItemValue("ImailAddress", email)
Call doc.Save(True, False)
End If
End If
Set doc = view.GetNextDocument(doc)
Wend
Messagebox "System updated. Thank you for your collaboration."
End Sub