Het volgende ik wil een listbox vullen met gegevens van contact die ik haal uit outlook. Dit heb ik al werkend, ik wil alleen zodra ik mijn programma start dat hij deze vult.
Hoe moet ik dit doen..want ik krijg met deze code elke keer een nullPointerException terwijl hij in de debug mode wel goed de namen doorloopt.
Wanneer ik voor oCt.FullName -- I invul dan laat hij deze nummers wel goed zien.
Hoe kan dat?
Hoe moet ik dit doen..want ik krijg met deze code elke keer een nullPointerException terwijl hij in de debug mode wel goed de namen doorloopt.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| Public Class Form1
Inherits System.Windows.Forms.Form
'connect to outlook
' Create Outlook application.
Dim oApp As Outlook.Application = New Outlook.Application
' Get namespace and Contacts folder reference.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim cContacts As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
' Get the first contact from the Contacts folder.
Dim oItems As Outlook.Items = cContacts.Items
Dim oCt As Outlook.ContactItem
Dim oCount = cContacts.Items.Count()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLaden.Click
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dit stuk is van belang om mijn listbox te vullen.
For I As Integer = 1 To oCount
Me.oCt = oItems.GetNext()
'fill the combobox with the addressbook members
Me.ListBox1.Items.Add(oCt.FullName)
Next
'Tot hier
End Sub
End Class |
Wanneer ik voor oCt.FullName -- I invul dan laat hij deze nummers wel goed zien.
Hoe kan dat?
[ Voor 49% gewijzigd door Verwijderd op 15-04-2004 18:29 ]