![Phân tích tư tưởng của nhân dân qua đoạn thơ: Những người vợ nhớ chồng… Những cuộc đời đã hóa sông núi ta trong Đất nước của Nguyễn Khoa Điềm](https://timtailieu.net/upload/document/136415/phan-tich-tu-tuong-cua-nhan-dan-qua-doan-tho-039-039-nhung-nguoi-vo-nho-chong-nhung-cuoc-doi-da-hoa-song-nui-ta-039-039-trong-dat-nuoc-cua-nguyen-khoa-136415.jpg)
Connecting to Exchange or Outlook
Số trang: 3
Loại file: pdf
Dung lượng: 16.26 KB
Lượt xem: 4
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
[ Team LiB ] Recipe 1.10 Connecting to Exchange or Outlook Problem You want to use ADO.NET 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
Nội dung trích xuất từ tài liệu:
Connecting to Exchange or Outlook[ Team LiB ]Recipe 1.10 Connecting to Exchange or OutlookProblemYou want to use ADO.NET to extract data from Microsoft Outlook or MicrosoftExchange.SolutionUse the OLE DB Jet provider to access Exchange and Outlook data.The sample code contains two event handlers:Form.Load Displays a form that allows the user to specify the mailbox name and mail profile to connect to.Connect Button.Click 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: ConnectExchangeDataForm.cs// Namespaces, variables, and constantsusing System;using System.Windows.Forms;using System.Data;using System.Data.OleDb;// . . .private void ConnectExchangeDataForm_Load(object sender, System.EventArgs e){ mailboxNameTextBox.Text = Personal Folders; profileTextBox.Text = Outlook;}private void connectButton_Click(object sender, System.EventArgs e){ String sqlText = SELECT Subject, Contents FROM Inbox; // Build the connection string. String connectionString=Provider=Microsoft.Jet.OLEDB.4.0; + Outlook 9.0; + MAPILEVEL= + mailboxNameTextBox.Text + |; + PROFILE= + profileTextBox.Text + ; + TABLETYPE=0; + DATABASE= + System.IO.Path.GetTempPath( ); // Create the DataAdapter. OleDbDataAdapter da = new OleDbDataAdapter(sqlText, connectionString); // Create and fill the table. DataTable dt = new DataTable(Inbox); try { da.Fill(dt); dataGrid.DataSource = dt.DefaultView; } catch(Exception ex) { MessageBox.Show(ERROR: + ex.Message); return; }}DiscussionThe .NET data provider for OLE DB does not support OLE DB Version 2.5 interfacesincluding the Microsoft OLE DB Provider for Exchange. The Jet OLE DB provider canaccess an Outlook or Exchange store. An example of the connection string:Microsoft.Jet.OLEDB.4.0;Outlook 9.0;MAPILEVEL=Personal Folders|; PROFILE=Outlook;TABLETYPE=0;DATABASE=c:\temp;The connection string attributes-and-value pairs are described in Table 1-1. Table 1-1. Outlook or Exchange connection string attributes Element Description DATABASE=pathDatabase With an Identifier of Outlook 9.0, the path to store temporary system tables.name With an Identifier of Exchange 4.0, the path and filename to a Microsoft Access database in which to store temporary system tables. Outlook 9.0 to connect to Outlook 2000 and later.Identifier Exchange 4.0 to connect to Exchange 4.x and 5.x. PASSWORD=passwordPassword Outlook or Exchange password. This parameter is not required if your network logon password is passed to the Outlook or Exchange server. This parameter is optional. PROFILE=profileProfilename The name of the Outlook or Exchange profile to use. If this not specified, the default profile is used. MAPILEVEL=| is the exact mailbox name on the server, a personal folder, or public folder as it appears in the Outlook Folder list.Tablepath is the path to the folder immediately above the folder to access using the SQL statement. The folder path is required only when accessing folders below the top level of folders within the store; the pipe (|) character is always required. When listing nested folders, separate each folder name with a backslash (\). TABLETYPE=0 for folders (default value).Tabletype TABLETYPE=1 for address books.[ Team LiB ]
Nội dung trích xuất từ tài liệu:
Connecting to Exchange or Outlook[ Team LiB ]Recipe 1.10 Connecting to Exchange or OutlookProblemYou want to use ADO.NET to extract data from Microsoft Outlook or MicrosoftExchange.SolutionUse the OLE DB Jet provider to access Exchange and Outlook data.The sample code contains two event handlers:Form.Load Displays a form that allows the user to specify the mailbox name and mail profile to connect to.Connect Button.Click 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: ConnectExchangeDataForm.cs// Namespaces, variables, and constantsusing System;using System.Windows.Forms;using System.Data;using System.Data.OleDb;// . . .private void ConnectExchangeDataForm_Load(object sender, System.EventArgs e){ mailboxNameTextBox.Text = Personal Folders; profileTextBox.Text = Outlook;}private void connectButton_Click(object sender, System.EventArgs e){ String sqlText = SELECT Subject, Contents FROM Inbox; // Build the connection string. String connectionString=Provider=Microsoft.Jet.OLEDB.4.0; + Outlook 9.0; + MAPILEVEL= + mailboxNameTextBox.Text + |; + PROFILE= + profileTextBox.Text + ; + TABLETYPE=0; + DATABASE= + System.IO.Path.GetTempPath( ); // Create the DataAdapter. OleDbDataAdapter da = new OleDbDataAdapter(sqlText, connectionString); // Create and fill the table. DataTable dt = new DataTable(Inbox); try { da.Fill(dt); dataGrid.DataSource = dt.DefaultView; } catch(Exception ex) { MessageBox.Show(ERROR: + ex.Message); return; }}DiscussionThe .NET data provider for OLE DB does not support OLE DB Version 2.5 interfacesincluding the Microsoft OLE DB Provider for Exchange. The Jet OLE DB provider canaccess an Outlook or Exchange store. An example of the connection string:Microsoft.Jet.OLEDB.4.0;Outlook 9.0;MAPILEVEL=Personal Folders|; PROFILE=Outlook;TABLETYPE=0;DATABASE=c:\temp;The connection string attributes-and-value pairs are described in Table 1-1. Table 1-1. Outlook or Exchange connection string attributes Element Description DATABASE=pathDatabase With an Identifier of Outlook 9.0, the path to store temporary system tables.name With an Identifier of Exchange 4.0, the path and filename to a Microsoft Access database in which to store temporary system tables. Outlook 9.0 to connect to Outlook 2000 and later.Identifier Exchange 4.0 to connect to Exchange 4.x and 5.x. PASSWORD=passwordPassword Outlook or Exchange password. This parameter is not required if your network logon password is passed to the Outlook or Exchange server. This parameter is optional. PROFILE=profileProfilename The name of the Outlook or Exchange profile to use. If this not specified, the default profile is used. MAPILEVEL=| is the exact mailbox name on the server, a personal folder, or public folder as it appears in the Outlook Folder list.Tablepath is the path to the folder immediately above the folder to access using the SQL statement. The folder path is required only when accessing folders below the top level of folders within the store; the pipe (|) character is always required. When listing nested folders, separate each folder name with a backslash (\). TABLETYPE=0 for folders (default value).Tabletype TABLETYPE=1 for address books.[ Team LiB ]
Tìm kiếm theo từ khóa liên quan:
công nghệ thông tin kỹ thuật lập trình Oreilly Ado Dot Net Cookbook Ebook-Lib Connecting to Exchange or OutlookTài liệu liên quan:
-
52 trang 444 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 334 0 0 -
74 trang 312 0 0
-
96 trang 310 0 0
-
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 300 0 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 295 0 0 -
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 293 1 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 283 0 0 -
EBay - Internet và câu chuyện thần kỳ: Phần 1
143 trang 282 0 0 -
Tài liệu hướng dẫn sử dụng thư điện tử tài nguyên và môi trường
72 trang 276 0 0