我是 vb.net 開發的新手,我必須閱讀位于磁盤目錄 (D:\mails\to-read\message1.msg, D:\mails) 中的 Outlook 電子郵件檔案中的資訊(主題、正文、...) \to-read\message2.msg, ...)。
可能嗎 ?
你能解釋一下嗎?舉個例子?
謝謝你的幫助。
uj5u.com熱心網友回復:
如果 Outlook 物件模型(Outlook 自動化)是一個可能的選項,您可以使用NameSpace.OpenSharedItem方法從指定的路徑或 URL 打開共享專案。此方法用于打開 iCalendar 約會 (.ics) 檔案、vCard (.vcf) 檔案和 Outlook 訊息 (.msg) 檔案。因此,在代碼中,您將獲得一個MailItem物件,您可以在其中獲得所有必需的屬性。
Public Sub TestOpenSharedItem()
Dim oNamespace As Outlook.NameSpace
Dim oSharedItem As Outlook.MailItem
Dim oFolder As Outlook.Folder
' Get a reference to a NameSpace object.
Set oNamespace = Application.GetNamespace("MAPI")'Open the Signed Message (.msg) file containing the shared item.
Set oSharedItem = oNamespace.OpenSharedItem("C:\Temp\RegularMessage.msg")
MsgBox oSharedItem.Subject
oSharedItem.Close (olDiscard)
Set oSharedItem = Nothing
Set oSharedItem = Nothing
Set oFSO = Nothing
Set oNamespace = Nothing
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/490848.html
