I want to change the e-mail address of all contacts in Outlook to lowercase and remove whitespaces.
These contacts use a custom form hence the IPM.Contact.112607Code:Sub ReFileContacts() Dim items As items, item As ContactItem, folder As folder Dim contactItems As Outlook.items Dim itemContact As Outlook.ContactItem Set folder = Session.GetDefaultFolder(olFolderContacts) Set items = folder.items Count = items.Count If Count = 0 Then MsgBox "Nothing to do!" Exit Sub End If 'Filter on the message class to obtain only contact items in the folder Set contactItems = items.Restrict("[MessageClass]='IPM.Contact.112607'") For Each itemContact In contactItems 'Loop through all contacts itemContact.Email1Address = LCase(Trim(Replace(itemContact.Email1Address))) itemContact.Save 'Save the contact Next MsgBox "Your contacts have been converted to lowercase without whitespaces." End Sub
When I run this (Contact folder has 20.000 contacts) I get the following error:
runtime error -1836974071 (92820009)
one or more items in the folder you synchronized do not match.
to resolve the conflicts, open the items and try the operation again
I really have no idea where to go from here...
I did NOT expect this kind of error.
If you run this script in your Outlook, you will definitely not get this error.
If you do, make sure you change
Set contactItems = items.Restrict("[MessageClass]='IPM.Contact.112607'")
to your corresponding form.
Please note:
I know that the field is called Email1Address because msgbox(itemContact.Email1Address) returns the E-mail address value.
Thank you!


Reply With Quote