I have written an application using VB 2005 that populates a combo box with email addresses from the user's Outlook Address book. It works great with Outlook but I can't get it to work with Outlook Express. How can i get it to work with Outlook Express?
Here is the code that works with Outlook (I found the code from the web):
CODE
Sub Main()
' Create Outlook application.
Dim oApp As Outlook.Application = New Outlook.Application()
' Get NameSpace and Logon.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon("Outlook", Missing.Value, False, True) ' TODO:
' Get the first contact from the Contacts folder.
Dim cContacts As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
Dim oItems As Outlook.Items = cContacts.Items
'Dim oCt As Outlook.ContactItem
Dim oCt As Outlook.ContactItem
Try
oCt = oItems.GetFirst()
'Display some common properties.
Console.WriteLine(oCt.FirstName)
Console.WriteLine(oCt.Title)
Console.WriteLine(oCt.CompanyName)
Console.WriteLine(oCt.Body)
Console.WriteLine(oCt.FileAs)
Console.WriteLine(oCt.Email1Address)
Console.WriteLine(oCt.Subject)
Console.WriteLine(oCt.JobTitle)
Catch
Console.WriteLine("an error occurred")
Finally
' Display
'oCt.Display(True)
' Log off.
'oNS.Logoff()
'' Clean up.
'oApp = Nothing
'oNS = Nothing
'oItems = Nothing
'oCt = Nothing
End Try
End Sub
End Module
Thanks in advance,
RotorTorque