Outlook 會提供許多您可以與之互動的類別。下列各節將簡述某些最上層類別,並描述它們彼此的互動關係。這些類別包括:
- Microsoft.Office.Interop.Outlook.Application
- Microsoft.Office.Interop.Outlook.Explorer
- Microsoft.Office.Interop.Outlook.Inspector
- Microsoft.Office.Interop.Outlook.MAPIFolder
- Microsoft.Office.Interop.Outlook.MailItem
- Microsoft.Office.Interop.Outlook.AppointmentItem
- Microsoft.Office.Interop.Outlook.TaskItem
- Microsoft.Office.Interop.Outlook.ContactItem
下面是範例程式:
首先在專案參考內先匯入Microsoft.Office.Interop.Outlook
接著是取出msg檔內各欄位的方式
Microsoft.Office.Interop.Outlook.Application app = null; Microsoft.Office.Interop.Outlook.MailItem item = null; DialogResult msgFileSelectResult = this.openFileDialog.ShowDialog(); if (msgFileSelectResult == DialogResult.OK) { string msgfile = this.openFileDialog.FileName app = new Microsoft.Office.Interop.Outlook.Application(); item = app.Session.OpenSharedItem(msgfile) as Microsoft.Office.Interop.Outlook.MailItem; this.label1.Text = item.Subject; this.label2.Text = item.SenderName; this.label3.Text = item.To; this.label4.Text = item.Body; }
沒有留言:
張貼留言