我正在尝试将 MS Outlook 集成到 asp.net 中。我的代码(如下)捕获越界错误。我究竟做错了什么?我没有正确收到收件箱消息吗?提前致谢
编辑:基于我的调试
inbox = name.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
不返回任何内容。我不知道为什么
Dim ol As Outlook.Application = New Outlook.Application
Dim name As Microsoft.Office.Interop.Outlook._NameSpace
Dim inbox As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim item As Microsoft.Office.Interop.Outlook.PostItem
Dim subF As Microsoft.Office.Interop.Outlook.MAPIFolder
Try
name = ol.GetNamespace("MAPI")
name.Logon(Nothing, Nothing, False, False)
inbox = name.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox)
subF = inbox.Folders(0)
Dim ctr As Integer
For ctr = 0 To subF.Items.Count
item = subF.Items(ctr)
Label1.Text += "Subject: " + item.Subject + "<br/>"
Label1.Text += "Date: " + item.SentOn.ToLongDateString() + " " + item.SentOn.ToLongTimeString() + "<br/>"
Label1.Text += "Category: " + item.Categories + "<br/>"
Label1.Text += "Body: " + item.Body + "<br/>"
Label1.Text += "HtmlBody: " + item.HTMLBody + "<br/>"
Next
Catch ex As System.Runtime.InteropServices.COMException
End Try