我試圖使用下面的給定過程來下載唯一的郵件,但出現錯誤(91對象變量或塊變量未設置) 錯誤行:。 FindFirst "task =""" & Mailobject.UserProperties.Find("taskID") & """"
錯誤91:對象變量或塊變量未設置需要幫助
Private Sub getml()
Dim rst As DAO.Recordset
Dim OlApp As Outlook.Application
Dim inbox As Outlook.MAPIFolder
Dim inboxItems As Outlook.Items
Dim Mailobject As Object
Dim db As DAO.Database
Dim dealer As Integer
Set db = CurrentDb
Set OlApp = CreateObject("Outlook.Application")
Set inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
Set rst= CurrentDb.OpenRecordset("mls")
Set inboxItems = inbox.Items
For Each Mailobject In inboxItems
With rst
.FindFirst "task =""" & Mailobject.UserProperties.Find("taskID") & """"
If .NoMatch
.AddNew
!task= Mailobject.UserProperties.Find("taskID")
!tsktml= Mailobject.UserProperties.Find("timeline")
.Update
Mailobject.UnRead = False
End If
End With
End If
Next
Set OlApp = Nothing
Set inbox = Nothing
Set inboxItems = Nothing
Set Mailobject = Nothing
End Sub
我試圖調試代碼並找出錯誤。變體var在搜索完所有郵件後顯示空值。即var返回taskid直到最後一封郵件,但在搜索最後一封郵件之後,而不是退出for語句代碼後再次循環郵件並顯示錯誤。所以我認爲我需要申請一個出口來幫助你應用它。 – Supernova