rodchar,
Unfortunately to give you a quick sample that works, would require that I
charge you for 40+ hours of work... Using Cor's example of manually copying
the data into a dataset might be the easiest way, especially for a novice.
The other option might be to find a Grid (such as the "Microsoft Office
Outlook View Control") that displays Outlook data natively.
http://support.microsoft.com/search/default.aspx?qu=Outlook+View+Control
The problem with the wrapper & Cor's method is that you are going to get the
security prompt as it will appear you are harvesting addresses to send spam,
or worse virures, to your unsuspecting friends...
As I stated Outlook is firmly rooted in the COM world. .NET is the .NET
world, using Interop you can cross between these two worlds, largely
transparently which is great. .NET is based on Classes, where as COM is
based on Interfaces. When you define a variable of a COM object (such as
Outlook.Items) you are actually dealing with a RCW (Runtime Callable
Wrapper) that works closely with the COM interface of the COM object...
However! certain features, such as DataBinding require "full" .NET support.
It requires an actual Class to get the list of properties (fields) to show,
when you try to bind to Outlook (even with the wrapper) each item (row) is a
__ComObject (the RCW), these __ComObjects don't know about the properties
that Outlook is able to give, as Outlook can only return an Interface. To
get the wrapper to work the wrapper would need to implement the ITypedList
interface also, which allows the wrapper to return the list of properties
the object being bound to supports. Plus it would need to implement an
ItemWrapper also that is able to take the property from ITypedList & convert
it into an the respective Outlook property...
The other problem you are going to run into, when using any of the three
methods) is that the Outlook folders contain different types of Objects. For
example the inbox will contain Outlook.MailItem objects, plus
Outlook.MeetingItem if you got a meeting request, plus possibly a handful of
other types...
Here is a simply wrapper for the Outlook.Items collection.
NOTE: It does not work as the Grid cannot bind to the interfaces that
Outlook returns, that would require addition work:
Option Strict On
Option Explicit On
Imports Outlook = Microsoft.Office.Interop.Outlook
Public Class OutlookItemCollection
Implements IList
Private ReadOnly m_items As Outlook.Items
Private ReadOnly m_syncRoot As Object
Public Sub New(ByVal items As Outlook.Items)
m_items = items
End Sub
#Region " IList implementation "
Public Sub CopyTo(ByVal array As System.Array, ByVal index As Integer)
Implements System.Collections.ICollection.CopyTo
Throw New NotImplementedException
End Sub
Public ReadOnly Property Count() As Integer Implements
System.Collections.ICollection.Count
Get
Return m_items.Count
End Get
End Property
Public ReadOnly Property IsSynchronized() As Boolean Implements
System.Collections.ICollection.IsSynchronized
Get
Return False
End Get
End Property
Public ReadOnly Property SyncRoot() As Object Implements
System.Collections.ICollection.SyncRoot
Get
Return m_syncRoot
End Get
End Property
Public Function GetEnumerator() As System.Collections.IEnumerator
Implements System.Collections.IEnumerable.GetEnumerator
Return m_items.GetEnumerator()
End Function
Public Function Add(ByVal value As Object) As Integer Implements
System.Collections.IList.Add
m_items.Add(value)
End Function
Public Sub Clear() Implements System.Collections.IList.Clear
Throw New NotImplementedException
End Sub
Public Function Contains(ByVal value As Object) As Boolean Implements
System.Collections.IList.Contains
Throw New NotImplementedException
End Function
Public Function IndexOf(ByVal value As Object) As Integer Implements
System.Collections.IList.IndexOf
Throw New NotImplementedException
End Function
Public Sub Insert(ByVal index As Integer, ByVal value As Object)
Implements System.Collections.IList.Insert
Throw New NotImplementedException
End Sub
Public ReadOnly Property IsFixedSize() As Boolean Implements
System.Collections.IList.IsFixedSize
Get
Return False
End Get
End Property
Public ReadOnly Property IsReadOnly() As Boolean Implements
System.Collections.IList.IsReadOnly
Get
Return False
End Get
End Property
Default Public Property Item(ByVal index As Integer) As Object
Implements System.Collections.IList.Item
Get
Return m_items(index + 1)
End Get
Set(ByVal value As Object)
Throw New NotImplementedException
End Set
End Property
Public Sub Remove(ByVal value As Object) Implements
System.Collections.IList.Remove
Throw New NotImplementedException
End Sub
Public Sub RemoveAt(ByVal index As Integer) Implements
System.Collections.IList.RemoveAt
Throw New NotImplementedException
End Sub
#End Region
End Class
Hope this helps
Jay