我正在尝试创建一些代码,将电子邮件正文复制到新的 Excel 电子表格中。我有这个代码:
Public Sub ExportToExcel1()
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim myitem As Outlook.MailItem
Dim FileName As String
Dim i As Integer
Dim objSearchFolder As Outlook.MAPIFolder
Dim item As Object
Dim mai As MailItem
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox).Folders("Hold Info")
Set objSearchFolder = Inbox
i = 0
For Each item In Inbox.Items
item.Display
item.Body.Select
Selection.Copy
Dim xlApp As Object ' Excel.Application
Dim xlWkb As Object ' Excel.Workbook
Set xlApp = CreateObject("Excel.Application") ' New Excel.Application
Set xlWkb = xlApp.Workbooks.Add
xlApp.Visible = True
xlApp.Workbooks.Add
xlApp.Selection.Paste False, False, False
Next
End Sub
它一直给我一个错误,item.Body.Select
我不知道为什么。这可能与我试图复制的电子邮件只不过是在 Oracle 中生成的表有关,但我不知道。