Hi John,
Right-click on your Project (or the References just under it) in the
Solution Explorer and select "Add Reference..."
Click on the COM tab and go looking for Microsoft Outlook. Select this to
get it into the Selected Components box below. Hit Ok.
This will add the reference to the project.
Now, at the top.of the Form/Class/Module that will interact with Outlook,
add
Imports Outlook
Imports System.Runtime.InteropServices.Marshal
The first will provide access to Outlook The second is required for
releasing COM objects (which is what Outlook gives you).
To use Outlook, you'll need:
Dim oOutlook As Outlook.Application
'The Email source within Outlook.
Dim oMailStore As Outlook.NameSpace
oOutlook = New Outlook.Application
'oOutlook.ActiveExplorer.ShowPane (Outlook.OlPane.olFolderList, True)
oMailStore = oOutlook.GetNamespace ("MAPI")
oMailStore gets you the namespace of the InBox and Mail folders.
oMailStore.Folders will get you the folders themselves.
oMailStore.Folders.GetFirst will get you the first of these.
To finish off:
If Not g_oMailStore Is Nothing Then
oMailStore.Logoff()
ReleaseComObject (oMailStore)
oMailStore = Nothing
End If
If Not g_oOutlook Is Nothing Then
oOutlook.Session.Logoff()
ReleaseComObject (oOutlook)
oOutlook = Nothing
End If
That should get you started.
Regards,
Fergus