我已经在 Outlook 中设置了一个宏并且它正在工作,但是在过去几天它已经停止将收到的电子邮件归档到特定文件夹并出现运行时错误 438 对象不支持此属性或方法错误
首先是代码:
Dim ns As Outlook.NameSpace
Dim objItem As Object
Dim FolderInbox As Folder
Dim MyItem As Outlook.MailItem
'// Added - A collection to hold the IDs of message to be deleted
Dim cMAILS As Collection
Set ns = Application.GetNamespace("MAPI")
Set FolderInbox = ns.GetDefaultFolder(olFolderInbox)
Set cMAILS = New Collection
For Each objItem In FolderInbox.Items
' here is the error
If objItem.ReceivedTime < Now - 50 And objItem.FlagStatus = 1 Then
' Here is a series of code in place
' to move copies of messages to different folder
Next
On Error Resume Next
Do While cMAILS.Count > 0
Set MyItem = ns.GetItemFromID(cMAILS(1))
If Not MyItem Is Nothing Then
MyItem.Delete
End If
cMAILS.Remove (1)
Loop
有错误的行是:
If objItem.ReceivedTime < Now - 50 And objItem.FlagStatus = 1 Then