tailieunhanh - Connecting to Exchange or Outlook

[ Team LiB ] Recipe Connecting to Exchange or Outlook Problem You want to use to extract data from Microsoft Outlook or Microsoft Exchange. Solution Use the OLE DB Jet provider to access Exchange and Outlook data. The sample code contains two event handlers | Team LiB Recipe Connecting to Exchange or Outlook Problem You want to use to extract data from Microsoft Outlook or Microsoft Exchange. Solution Use the OLE DB Jet provider to access Exchange and Outlook data. The sample code contains two event handlers Displays a form that allows the user to specify the mailbox name and mail profile to connect to. Connect Creates and opens a connection to Outlook or Exchange data using the OLE DB .NET data provider. A DataAdapter is used to fill a table with the Subject and Content of each message in the Inbox. The default view of the table is bound to a data grid on the form. The C code is shown in Example 1-8. Example 1-8. File Namespaces variables and constants using System using using using . . . private void ConnectExchangeDataForm_Load object sender e Personal Folders Outlook private void connectButton_Click object sender e String sqlText SELECT Subject Contents FROM Inbox Build the connection string. String connectionString Provider Outlook MAPILEVEL PROFILE TABLETYPE 0 DATABASE Create the DataAdapter. OleDbDataAdapter da new OleDbDataAdapter sqlText connectionString Create and fill the table. DataTable dt new DataTable Inbox try dt catch Exception ex ERROR return Discussion The .NET data provider for OLE DB does not support OLE DB Version interfaces including the Microsoft OLE DB Provider for Exchange. The Jet OLE DB provider can access an Outlook or Exchange store. An example of the connection string Outlook MAPILEVEL Personal Folders PROFILE Outlook TABLETYPE 0 DATABASE c temp The connection string attributes-and-value pairs are .