Retrieving email address

nibsy

Well-known member
Joined
Aug 7, 2002
Messages
51
Location
Kent, UK
I am trying to retrieve an email address from my contacts within outlook.

When trying to create an instance of Outlook using the following code:

[VB]
Dim objOutlook As New Outlook.Application()
[/VB]

I receive the following error "Type Outlook.Application is not defined"

What am I missing?
Thanks in-advance
 
I found the answer:

A reference to the COM object had to be added.

This was done from the menu

Project -> Add Reference -> Microsoft Outlook 10.0 Object Libarary
 
I only have Outlook 9.0 Object Library. It does not let me create the outlook.application object.

Do I need and can I obtain Outlook 10.0 Object Library?

Thanks.
 
using msOutl9 = Microsoft.Office.Interop.Outlook;

...

msOutl9.Application objOutlook = new msOutl9.ApplicationClass();
msOutl9.NameSpace objNS = objOutlook.GetNamespace("MAPI");
objNS.Logon ("Outlook", "net", false, true);
msOutl9.Items oItems;
msOutl9.ContactItem oContact;
msOutl9.MAPIFolder cContacts = objNS.GetDefaultFolder (msOutl9.OlDefaultFolders.olFolderContacts);
oItems = cContacts.Items;
oContact = (msOutl9.ContactItem) oItems.GetFirst();
listBox1.Items.Add (oContact.FullName + ": " + oContact.Email1Address);
...
 
Back
Top