我想使用 Visual Studio 2022 读取 .msg 文件 VB .Net。每当我尝试时,都会收到以下错误。我的示例代码:
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim filePath As String = "C:\Email\Source\Tet.msg"
Dim outlookApp As New Outlook.Application()
Dim mailItem As Outlook.MailItem = outlookApp.CreateItemFromTemplate(filePath)
Dim subject As String = mailItem.Subject
Dim body As String = mailItem.Body
End Sub
End Class
错误如下:
System.IO.FileNotFoundException: 'Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. The system cannot find the file specified.'
引用的 Outlook 版本错误。