由于某些原因,VBA没有从Outlook中提取电子邮件的正文。在完成的先前任务中,我已使用此确切代码使用“ OutlookApp.Subject”和“ OutlookApp.receivedtime”导入主题和接收日期。我为什么不能拉出身体有原因吗?我不知道的是Outlook中的证券是否会阻止我通过VBA访问Outlook电子邮件正文。我正在使用Microsoft Outlook 16.0对象库参考。我在以下行“ Range(“ Date”)。Offset(i,0).Value = OutlookMail.Body“上收到错误。该错误指出“运行时错误'287'应用程序定义的错误或对象定义的错误”。
Sub Auto_Open()
Dim OutlookApp As Outlook.Application
Dim OutlookNameSpace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
Dim Filler() As String
Set OutlookApp = New Outlook.Application
Set OutlookNameSpace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNameSpace.getdefaultfolder(olFolderInbox).Folders("MOT Extension")
i = 1
For Each OutlookMail In Folder.items
If OutlookMail.receivedtime >= Range("Original_Date").Value Then
Range("Date").Offset(i, 0).Value = OutlookMail.Body
Range("Date").Offset(i, 0).VerticalAlignment = xlTop
i = i + 1
End If
Next OutlookMail
Set Folder = Nothing
Set OutlookNameSpace = Nothing
Set OutlookApp = Nothing
End Sub