Results 1 to 8 of 8

Thread: Can you 'find' a contact from code in outlook - Resolved

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Can you 'find' a contact from code in outlook - Resolved

    I'm writing an app that will populate contacts from a database into outlook. I've stored the contact reference from the database in the customerID field of the contact in outlook (I chose the customerID field arbitrarily if anyone knows a better one which isn't visible to the user, please let me know)

    I now want to be able to find a given contact in outlook from the db reference. Is there a simple way of doing this?

    If there's not an outlook API call I could write a recursive algorithm that searched through the contacts folder and sub folders checking the customerID field of each contact it finds but I suspect that might be a little on the slow side. Any better suggestions?
    Last edited by FunkyDexter; Jun 15th, 2005 at 04:31 AM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Can you 'find' a contact from code in outlook

    The .EntryID field of any Outlook object is the way to go. You even have a function to get a specific item.
    VB Code:
    1. Dim oContact As Outlook.ContactItem
    2.     Set oContact = Application.GetNamespace("MAPI").GetItemFromID("EntryID", "EntryIDStore")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Can you 'find' a contact from code in outlook

    Oooh! That sounds like what I'm after . Does the GetItemFromID method search subfolders or just the folder it's called against?

  4. #4

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Can you 'find' a contact from code in outlook

    When I came to try it out I realised I displayed my ignorance with that last question

    Since I'm calling it against the namespace (not a mapi folder) it must search the whole structure - otherwise it wouldn't make sense. That's a really elegant solution RobDogg, thanks.

  5. #5

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Can you 'find' a contact from code in outlook

    Bah, I knew it was too good to be true.

    I can't use entryID because it's read only and auto assigned by outlook when the item is created so that idea's ed. I considered keeping a table in the db that paired outlook entryID with the db reference but I've read that the entryID changes if you move the item between folders in outlook so that won't work either.

    Any more ideas folks?

    p.s. I've always wanted to use the duck

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Can you 'find' a contact from code in outlook

    The .EntryID is read only because its the serial number of the item in Outlook in a particular Mailbox or Store (pst file). It does
    not change if you move it between folders. Once an item is created and saved the .EntryID is generated and will stay with the
    item for as long as it exists in Outlook.

    Maybe I dont understand how you need to use it? If you have the ContactItem in Outlook and you want to also save it to Access then it
    will have the .EntryID. If the item is in Access and not Outlook yet, then save it to Outlook and retrieve the .EntryID property for saving
    back to the Access db so you can find it later.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Can you 'find' a contact from code in outlook

    I'm bringing contacts from a crm database into outlook rather than pushing contacts from outlook into a database. I wanted to store the reference from teh crm database against the contact in outlook so that, if the contact is changed in the crm database, I can find it again in outlook and update it.

    I must have missunderstood what I read about the entryID changing. I assume this must have been if you move it between stores. If it doesn't change within the same store I can just maintain a table in the crm database which matches the db reference against the outlook entryID. Thanks

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Can you 'find' a contact from code in outlook - Resolved

    That is correct. Only when moved between stores will it change.

    This should make you feel better:
    http://msdn.microsoft.com/library/de...HV05247424.asp

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width