LS.
I'm trying to update Outlook Contact attributes using CallByName, this because I do not know which attribute I will be setting at runtime. The attribute name (e.g. LastName) is passed to the function as a string as is the value it will be getting.
for all combinations of attributes and values I've tried I'm getting the error:
"Value does not fall within the expected range"
All combinations are valid when aplied manually to the same contact.
The same method is allowing me to get values but not to set values.
Anyone an idea?
The failing code that gives the "Value does not fall within the expected range" at line 14 (CallByName)
vb.net 4.0, Outlook 2010, VS 2012.
Thank you in advance!
Best regards, Ruud.
I'm trying to update Outlook Contact attributes using CallByName, this because I do not know which attribute I will be setting at runtime. The attribute name (e.g. LastName) is passed to the function as a string as is the value it will be getting.
for all combinations of attributes and values I've tried I'm getting the error:
"Value does not fall within the expected range"
All combinations are valid when aplied manually to the same contact.
The same method is allowing me to get values but not to set values.
Anyone an idea?
The failing code that gives the "Value does not fall within the expected range" at line 14 (CallByName)
Function UpdateContact(ByVal objOl As Outlook.Application, ByVal ID As String, strName As String, strNewValue As String) As String Dim objNS As Outlook.NameSpace Dim objContact As Outlook.ContactItem Dim objTemp As Object objNS = objOl.GetNamespace("MAPI") For Each objTemp In objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Items 'Check whether the object is actually a Contact as there can be other stuff in Outlook folders objContact = TryCast(objTemp, Outlook.ContactItem) If Not objContact Is Nothing Then If objContact.EntryID = ID Then 'MessageBox.Show("Contact Found: " & objContact.FirstName & " - " & objContact.LastName) CallByName(objContact, strName, CallType.Set, strNewValue) Return "0" End If End If Next Return "1" End Function 'UpdateContact
vb.net 4.0, Outlook 2010, VS 2012.
Thank you in advance!
Best regards, Ruud.