vba - 如何从桌面目录中的所有电子邮件模板中删除特定收件人?
问题描述
我有一个 Outlook 消息的目录文件夹(桌面上的文件夹)(.msg)
用作制作电子邮件的模板。
此文件夹中可能有 500 封电子邮件。我有时需要在每个月之后从每封电子邮件中删除一个特定的电子邮件地址。
Sub test()
Dim m As MailItem 'object/mail item iterator
Dim recip As Recipient 'object to represent recipient(s)
Dim email As Long
Set Remove = m.Remove
email = InputBox("Please enter the e-mail address you wish to remove")
answer = MsgBox("Are you sure you want to delete this e-mail?", vbYesNo + vbCritical, "Delete?")
If answer = vbYes Then
For Each m In Application.ActiveExplorer.Selection
If m.Class = olMail Then
Set Remove = m.Recipients.Remove(email)
End If
m.Save
End If
Next
End Sub
我如何用 VBA 做到这一点?
如果电子邮件有 johndoe@gmail.com,我希望在我在所有 TO、CC、BCC 等中运行此代码后删除该电子邮件。
解决方案
调用Application.Session.OpenSharedItem
每个 MSG 文件,删除收件人,调用MailItem.Save
.
推荐阅读
- javascript - 摩卡--检查-brk
似乎已停止工作 - 附加调试器时测试文件不运行 - python - 如何安装 R 包 movMF 以与 rpy2 一起使用?
- javascript - 仅在其他 async/await 函数解决后才调用函数
- apache - Apache2 服务器关闭 找不到私钥
- python-3.x - 访问类的属性不起作用?
- c++ - 使用 stbi_write_png 从 OpenGL 帧缓冲区保存的 PNG 向右移动
- json - jq遇到某个子值时找出父键
- python-3.x - 多线程请求 Python3
- java - 找到矩阵的重心
- mysql - 如何使用 MinGW-W64 编译 MySQL 连接器 C++?