Agent help - Change case from Mixed case to all lower case

I am trying to get this agent to change the case in the InternetAddress field of the DD. We are in the process of migrating to Exchange and if the field is propercase for the domain, freetime lookup fails. I am still in the testing phase and keep hitting the dreaded ‘Type Mismatch’ error. Any review and/or correction of this would be greatly appreciated.

Sub Initialize

Dim s As NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim item As NotesItem

Set s = New NotesSession

Set db = s.CurrentDatabase

Set view = db.GetView("by Internet Addresses")

Set doc = view.GetFirstDocument

Set item = doc.Contains(InternetAddress) 

While Not (doc Is Nothing)

	Call doc.ReplaceItemValue("Domain.com", "domain.com")

	Call doc.Save( True, True )

	Set doc = view.GetNextDocument( doc )

Wend		

End Sub

Thank you so very much!!

Subject: the problem is doc.Contains

  1. .contains operates on notesitem, not on doc. 2) you want to get the InternetAddress WITHIN your while loop, or you will only ever be using the address from the First doc

  2. That isn’t how replaceitemvalue works. you are essentially telling it to replace the value in the field “Domain.com” with “domain.com”.

So try something like:

dim imail as string

Set doc = view.GetFirstDocument

While Not (doc Is Nothing)

imail = doc.InternetAddress(0)

imail = Replace(imail, “Domain.com”, “domain.com”)

doc.InternetAddress = imail

Call doc.Save( True, True )

Set doc = view.GetNextDocument( doc )

Wend