Wednesday, May 12, 2010

Excel macro for Changing the Email address in Lotus Domino

This macro when run can read the Excel file & replace the old email address in person record with new email address.

 Excel Format:



Macro:



Sub ModifyForwardingaddress()

s.Initialize

Dim extendedaddressbook As NotesDatabase

Dim view As NotesView

Dim result As NotesDocumentCollection

Dim entry As NotesDocument

Set extendedaddressbook = s.GetDatabase("", "xdir.nsf", False)

For i = 2 To 3

ShortName = Trim(Cells(i, 2).Value)

newemailid = Trim(Cells(i, 4).Value)

strquery = "@LowerCase(ShortName)=" & Chr(34) & LCase(ShortName) & Chr(34)

Set result = extendedaddressbook.Search(strquery, Nothing, 0)

If result.Count = 1 Then

Set entry = result.GetFirstDocument

Call entry.ReplaceItemValue("Mailaddress", newemailid)

Call entry.Save(False, True)

Cells(i, 5).Value = 1

Else

Cells(i, 5).Value = 0

End If

Next

MsgBox "done"

End Sub

No comments:

Post a Comment