|
-
Jun 10th, 2005, 09:19 PM
#1
Thread Starter
Hyperactive Member
Outlook Contacts
Hi,can some one show me an example of extracting the outlook contacts to a listbox?,would be good just with pure api so no dlls etc thanks
-
Jun 10th, 2005, 09:24 PM
#2
Re: Outlook Contacts
API's are using dll's. Try using VBScript in VB. Google this for some excellent code "VBScript Outlook" without the quotes.
-
Jun 10th, 2005, 10:38 PM
#3
Junior Member
Re: Outlook Contacts
Code:
Private Sub Command1_Click()
Dim o As New Outlook.Application, ns As Outlook.Namespace
Dim fldr As Outlook.MAPIFolder, ctcItems As Outlook.Items
Dim j As Integer
Set ns = o.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(olFolderContacts)
Set ctcItems = fldr.Items
For j = 1 To ctcItems.Count
On Error Resume Next ' in case you encounter a distribution list
List1.AddItem ctcItems.Item(j).FullName
Next j
End Sub
Hope this helps
Last edited by Xiarcel; Jun 10th, 2005 at 10:49 PM.
-
Jun 11th, 2005, 07:40 AM
#4
Thread Starter
Hyperactive Member
Re: Outlook Contacts
what refrences do i need?
-
Jun 11th, 2005, 08:26 AM
#5
Re: Outlook Contacts
 Originally Posted by Mr_Zer0
what refrences do i need?
Microsoft Outlook xxx Object Library
Where xxx is the version nmber of your Outlook package 
Cheers,
RyanJ
-
Jun 11th, 2005, 09:09 AM
#6
Re: Outlook Contacts
You don't have to use references when you use VBScript in VB just to let you know. 
But his code requires it.
-
Jun 11th, 2005, 09:12 AM
#7
Re: Outlook Contacts
There are a couple of variations of what you could do.
You could use VB Script behind a Outlook Form to do this.
You could use VB6 to automate it like posted.
You could use early binding like posted.
You could use late binding so it will work without any references (vb script or vb6).
'...
'...
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 11th, 2005, 10:28 PM
#8
Junior Member
Re: Outlook Contacts
If you don't want to add references
Code:
Private Sub Command1_Click()
Dim o As Object, ns As Object
Dim fldr As Object, ctcItems As Object
Dim j As Integer
Dim ctc As Object
Set o = CreateObject("Outlook.Application")
Set ns = o.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(10)
Set ctcItems = fldr.Items
For j = 1 To ctcItems.Count
On Error Resume Next
List1.AddItem ctcItems.Item(j).FullName
Next j
End Sub
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
|