excel - 无法将电子邮件移动到另一个文件夹错误 438 对象不支持此属性或方法
问题描述
我正在尝试将具有特定主题的电子邮件标记为已读并将其移动到另一个文件夹。错误就行了.UnRead = False
。
此行导致错误 438。我尝试了myitem
具有相同结果的不同组合。
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As Outlook.MAPIFolder
Dim OutlookMail As Variant
Dim DestFolder As Outlook.MAPIFolder
Dim RetiredFolder As Outlook.MAPIFolder
Dim myItem As Object
Dim myItems As Outlook.MailItem
Application.ScreenUpdating = False
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Emails")
Set wsNS = wb.Worksheets("NS_Export")
ws.Activate
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.Folders("myemail").Folders("NOC Announcements New")
Set RetiredFolder = OutlookNamespace.Folders("tmyemail").Folders("Retired Buildings")
For Each OutlookMail In Folder.Items
Set myItem = Folder.Items.Find("[Subject] = 'The following building has been permanently retired'")
With myItem
.UnRead = False
.Move RetiredFolder
End With
Next OutlookMail
解决方案
用这个 :
Dim outlookmail As Outlook.MailItem
For Each outlookmail In Folder.Items
If TypeOf outlookmail Is MailItem Then
If outlookmail.Subject = "The following building has been permanently retired" Then
With outlookmail
.UnRead = False
.Move RetiredFolder
End With
End If
End If
Next outlookmail
推荐阅读
- android - Hyperledger Iroha Android - CommandService Stateless 无效 tx - 格式错误的 creator_account_id,传递值:'' -
- java - 了解构造函数的有界泛型参数
- java - 如果 readCount 为零,如何跳过 itemWriter
- hadoop - HRegionServer 启动错误
- google-chrome - 在 Chrome 中,我可以阻止 Google 搜索结果中的视频和图像吗?
- pandas - 将熊猫数据框转换为 snap.py
- css - 什么时候“首选最小宽度”大于 CSS 中的“可用宽度”?
- django - 带有 PostgreSQL 错误消息的 Django:django.db.utils.ProgrammingError:运算符不存在:bigint = boolean
- python - 如何提取一个单词及其所有依赖项
- php - 使用 PHP 在 CURL 的标头中发布参数和数组