我要在Outlook中检索邮件内容的部分出现Application defined or Object defined
错误。这是我的代码
Sub Import_Outlook_to_Excel()
Dim oitem As outlook.MailItem
Dim i As Long
Dim Body As String
Dim olapp As outlook.Application
Dim olappns As outlook.Namespace
Dim oinbox As outlook.Folder
Dim oFolder As outlook.MAPIFolder
i = 2 outlook
Set olapp = New outlook.Application
Set olappns = olapp.GetNamespace("MAPI")
Set oinbox = olappns.GetDefaultFolder(olFolderInbox).Folders("Winautomation")
For Each oitem In oinbox.Items
Sheets(1).Cells(i, 5).Value = oitem.Subject
Sheets(1).Cells(i, 6).Value = oitem.Body
i = i + 1
Next
End Sub