我试图使用下面的给定过程来下载唯一的邮件,但出现错误(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