|
-
Jun 10th, 2005, 10:33 AM
#1
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.
-
Jun 10th, 2005, 12:24 PM
#2
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:
Dim oContact As Outlook.ContactItem
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 13th, 2005, 03:08 AM
#3
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?
-
Jun 13th, 2005, 08:42 AM
#4
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.
-
Jun 13th, 2005, 09:36 AM
#5
-
Jun 13th, 2005, 11:06 AM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 15th, 2005, 04:30 AM
#7
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
-
Jun 15th, 2005, 11:09 AM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|