locked
How can I search mobile contacts RRS feed

  • Question

  • Hi all ...

    I need to know how to search phone contacts for a specific person , and retrieve its number ??

    How can I search phone contacts with uncomplete name ??

    ex : My name is Ashraf Fawzy , how can I retrieve the name if I used only "Ashr*" or "Fawzy"

    and of course it may return a bunch of contacts that match this case .... And that's ok to me.

    I'm looking for a code , or link to a topic with a code , Not MSDN Documentation.

    Many thanks in advance.

    Sunday, March 21, 2010 10:26 PM

Answers

  • Many thank for all your help , And after a little but of suffering,  here is the code

    Try
    Dim ols As OutlookSession = New OutlookSession()
    Dim iter As ContactCollection.ContactCollectionEnumerator = ols.Contacts.Items.GetEnumerator()
    
    Do While iter.MoveNext()
    If (iter.Current.FirstName.ToLower.Contains("Name you search for")) Then
    'and you can get the phone number (iter.Current.MobileTelephoneNumbe)            
    MsgBox(iter.Current.FirstName) & " contact is exist."
    End If
    Loop
    
    Catch ex As Exception
    MsgBox("SendContactNumber :- " & ex.Message)
    End Try

    I hope that may help someone else.

    Monday, March 22, 2010 5:08 PM

All replies

  • Hi Ashraf,

    I think LinQ suits for your requirement. Try to retrieve all contacts and then use Linq for this.

     

    Regards,

    Malleswar

    Monday, March 22, 2010 5:19 AM
  • Many thanks Malleswar for your reply ...

    But I heared that PocketOutLook can do this job easly , but I don't know how to write the code,

    If you or any one can provide a code .... It will be really appreciated.

    Many thanks in advance.

    Monday, March 22, 2010 11:08 AM
  • Hi,

    Yes you are correct. I suggested the same.

    In this link, they used LinQ with Outlook contacts, hope this helps you.

    http://community.softteq.com/blogs/nick/archive/2007/08/24/linq-differences.aspx

     

    Regards,

    Malleswar

    Monday, March 22, 2010 11:26 AM
  • Many thank for all your help , And after a little but of suffering,  here is the code

    Try
    Dim ols As OutlookSession = New OutlookSession()
    Dim iter As ContactCollection.ContactCollectionEnumerator = ols.Contacts.Items.GetEnumerator()
    
    Do While iter.MoveNext()
    If (iter.Current.FirstName.ToLower.Contains("Name you search for")) Then
    'and you can get the phone number (iter.Current.MobileTelephoneNumbe)            
    MsgBox(iter.Current.FirstName) & " contact is exist."
    End If
    Loop
    
    Catch ex As Exception
    MsgBox("SendContactNumber :- " & ex.Message)
    End Try

    I hope that may help someone else.

    Monday, March 22, 2010 5:08 PM
  • Many thank for all your help , And after a little but of suffering,  here is the code

    Try
    Dim ols As OutlookSession = New OutlookSession()
    Dim iter As ContactCollection.ContactCollectionEnumerator = ols.Contacts.Items.GetEnumerator()
    
    Do While iter.MoveNext()
    If (iter.Current.FirstName.ToLower.Contains("Name you search for")) Then
    'and you can get the phone number (iter.Current.MobileTelephoneNumbe)            
    MsgBox(iter.Current.FirstName) & " contact is exist."
    End If
    Loop
    
    Catch ex As Exception
    MsgBox("SendContactNumber :- " & ex.Message)
    End Try

    I hope that may help someone else.

    Monday, March 22, 2010 5:08 PM