473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Outlook Contacts

102 64KB
Background:

VS 2015 - VB Windows Form Application
SQL Server 2008
Outlook PRO 2016

I want to read my Outlook contacts (global address list) and put them in a datagridview or combo box. I have found some routines on the web but they do no work. I found this one but I get an empty combobox. What is wrong?

Thanks in advance for your help.

Expand|Select|Wrap|Line Numbers
  1. Imports System.Reflection
  2. Imports Microsoft.Office.Interop
  3. Public Class Form1
  4.  
  5.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  6.         Dim objOutlook As Microsoft.Office.Interop.Outlook._Application
  7.         'Outlook Namespace will be current session
  8.         Dim objNS As Microsoft.Office.Interop.Outlook._NameSpace
  9.  
  10.         'Initialise objects created in Form Load
  11.         objOutlook = New Microsoft.Office.Interop.Outlook.Application()
  12.         objNS = objOutlook.Session
  13.  
  14.         'Get the Contact folder
  15.         Dim objAddressList As Microsoft.Office.Interop.Outlook.MAPIFolder
  16.         objAddressList = objNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts)
  17.  
  18.         'Get all the contacts
  19.         Dim objItems As Microsoft.Office.Interop.Outlook.Items = objAddressList.Items
  20.         Dim objContact As Microsoft.Office.Interop.Outlook.ContactItem
  21.  
  22.  
  23.         For j = 1 To objItems.Count
  24.             If TypeOf (objContact) Is Microsoft.Office.Interop.Outlook.ContactItem Then
  25.                 objContact = objItems(j)
  26.                 Me.ComboBox1.Items.Add(objContact.Email1Address)
  27.             End If
  28.         Next
  29.  
  30.  
  31.         'clear memory
  32.         objContact = Nothing
  33.         objItems = Nothing
  34.         objAddressList = Nothing
  35.     End Sub
  36.  
  37.  
  38.  
  39. End Class
Jan 18 '17 #1
0 1543

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fritz Switzer | last post by:
Can anyone provide a small snippet in C# that pulls out the Contacts in Outlook XP. I've seen a couple of examples in C++ and VB in previous newsgroup posts, but either the originals didn't work...
2
by: Salad | last post by:
A2003, WinXP I know it is possible to link the Outlook contacts table to Access. Is it possible to call/open the Outlook Contacts window form within Access?
2
by: sfriedman | last post by:
I was able to successfully link my Outlook Contacts table to an Access Database and create an entry form. Unfortunately the Displayname field which is one of the key fields for how the contact is...
1
by: SWu | last post by:
Hello everyone, I am working on an Internet website for an Application Service Provider. A user can store employee details on the site. I am now researching the feasibility of accessing the...
2
by: Stefan | last post by:
Hello, at the moment i'm exporting outlook contacts to .csv files and then import the file into a sql contact table. i do this only once, so the inputter has to add new contacts twice. Now i...
3
by: John | last post by:
Hi I am trying to access outlook contacts folders and delete the contacts that do not contain a certain category value in the categories field. I have written the below code but am stuck with...
7
by: Chris Thunell | last post by:
I'm trying to loop through an exchange public folder contact list, get some information out of each item, and then put it into a vb.net datatable. I run though the code and all works fine until i...
1
by: tyronne | last post by:
I have created a data base that is linked to contacts in personA's outlook contacts, I need personB and PersonC to be able to also edit the data base which include a dropdown for personA's...
4
by: Corey66 | last post by:
Hello! I think, I have one simple question for you guys, but I don't get the answer by myself! I would like to import all "Outlook - Contacts" into my application and when I use "foreach" it...
0
by: Jason Ingalls | last post by:
Hi Everyone: I hope someone can figure out what I am missing as this is not working properly for me. Background: I was tasked with creating a database to store contact information in, which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.