Thanks a lot guys.
I will try Chuckyeggs code after I get the first one correct.
Erel - first I think you made a misstake with c.EMAIL_MOBILE, should it not be PHONE_MOBILE
But I still get a error with the message "Contact object should be set by calling one of the Contacts methods"
My code now looks like this:
Dim Contacts2 As Contacts2
Dim list1 As List
list1 = Contacts2.GetAll(False,False)
Dim listOfNames As List
listOfNames.Initialize
For i = 0 To list1.Size - 1
Dim c As Contact
c = list1.Get(i)
If c.DisplayName.IndexOf("@") = -1 Then
listOfNames.Add(c.DisplayName)
End If
Next
Dim res As Int
res = InputList(listOfNames, "Choose contact", -1)
If res <> DialogResponse.CANCEL Then
Dim name As String
name = listOfNames.Get(Res)
Dim c As Contact
Dim phones As Map
phones = c.GetPhones
Dim mobilePhone As String
For i = 0 To phones.Size - 1
If phones.GetValueAt(i) = c.PHONE_MOBILE Then
mobilePhone = phones.GetKeyAt(i)
Exit
End If
Next
If mobilePhone <> "" Then
edtNum.Text = mobilePhone
Else
edtNum.Text = "Contact without phone!"
End If