我正在尝试编写一个Outlook 2010加载项,它将迭代特定邮件文件夹中的所有项目,并从那里自动填充Excel电子表格。目前,我甚至无法访问默认的收件箱。我正在编写Visual Studio 2010 Pro中的加载项,并根据需要使用自动完成选项。我的问题是每当我运行我的代码时,即使只是设置基本变量,它也会给我一个“找不到对象”错误并抛出异常。我不知道出了什么问题,我非常感谢你的帮助。
Imports Microsoft.Office.Interop
Public Class ThisAddIn
Private Sub ThisAddIn_Startup() Handles Me.Startup
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.NameSpace
Dim olFolders As Object
Dim olReadFolder As Outlook.Folder
Dim readCollection As Microsoft.Office.Interop.Outlook.Items
Dim currentMessage As Outlook.MailItem
Dim exWorksheet As Excel.Worksheet
olApp = New Outlook.Application
olNamespace = olApp.GetNamespace("MAPI")
'olFolders = olNamespace.Folders
olReadFolder = olNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) '<-- Add-in fails here
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
End Sub
End Class