vba - Outlook 宏,用于保存来自特定人员/以特定标题开头的邮件的附件
问题描述
我需要编写一个 Outlook 宏来保存具有指定标题开头(例如:“报告..”)或指定发件人的邮件的附件。我还没有在 Outlook VBA 中编程,所以我不知道如何开始。你能帮我吗?
解决方案
我相信这会做你想要的。
Sub SetFlagIcon()
Const olFolderInbox = 6
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set colItems = objFolder.Items
For Each objMessage In colItems
If objMessage.SenderEmailAddress = "someone@gmail.com" Then
intCount = objMessage.Attachments.Count
If intCount > 0 Then
For i = 1 To intCount
objMessage.Attachments.Item(i).SaveAsFile "C:\your_path_here\Desktop\" & _
objMessage.Attachments.Item(i).FileName
Next
End If
End If
Next
End Sub
请参阅下面的链接,了解有关此操作的其他一些想法。
https://www.pixelchef.net/content/rule-autosave-attachment-outlook
推荐阅读
- java - 检测直线与矩形的交点
- amazon-web-services - 没有错误,但 AWS S3 同步根本不起作用
- java - Hystrix 设置超时时,不要更改它
- logging - 在 Kubernetes 属性上使用 Fluent Bit Modify Filter
- xamarin - 访问 .Net 标准项目库中的 Application.Current
- java - 将具有 NULL 值的本机查询结果转换为 POJO
- javascript - Firebase 使用效果重新渲染
- c# - 如何检查 catch 块中抛出的异常类型?
- python - 如何使用 python 读取 excel 上的数据,然后将单元格等同于不同的变量,例如。x、y、z 等
- numpy - 从 numpy 行向量中每第 5 和第 6 个元素切片