如何从Outlook中的电子邮件中删除特定类型的附件?
您是否曾尝试通过Outlook中的文件类型删除多个选定电子邮件中的附件? 如从所选电子邮件中删除所有docx或png附件文件。 你怎么能在Outlook中解决这个工作?
使用VBA代码从电子邮件中删除特定类型的附件
要从选定的电子邮件中删除特定类型的附件,以下VBA代码可以为您提供帮助,请按照以下步骤操作:
1。 选择您想要在邮件列表中删除其特定类型附件的电子邮件。
2。 按住 ALT + F11 键打开 Microsoft Visual Basic for Applications 窗口。
3。 然后,点击 插页 > 模块,将以下代码复制并粘贴到打开的空白模块中,请参阅截图:
VBA代码:从电子邮件中删除特定类型的附件:
Sub DeleteSpecificTypeOfAttachments() Dim xSelection As Outlook.Selection Dim xItem As Object Dim xMailItem As Outlook.MailItem Dim xAttachment As Outlook.Attachment Dim xFileType As String Dim xType As String Dim xFSO As Scripting.FileSystemObject Dim I As Integer On Error Resume Next Set xSelection = Outlook.Application.ActiveExplorer.Selection Set xFSO = New Scripting.FileSystemObject xType = "" xType = InputBox("Attachment Type:", "Kutools for Outlook", xType, 8) If Len(Trim(xType)) = 0 Then Exit Sub For Each xItem In xSelection If xItem.Class = olMail Then Set xMailItem = xItem If xMailItem.Attachments.Count > 0 Then For I = xMailItem.Attachments.Count To 1 Step -1 Set xAttachment = xMailItem.Attachments.Item(I) xFileType = xFSO.GetExtensionName(xAttachment.FileName) If InStr(xFileType, Trim(xType)) > 0 Then xAttachment.Delete End If Next I xMailItem.Save End If End If Next Set xMailItem = Nothing Set xFSO = Nothing End Sub
4。 然后还在 Microsoft Visual Basic for Applications 窗口中,单击 工具 > 参考文献 去 参考-Project1 对话框,并检查 Microsoft脚本运行时 选项从 可用的参考 列表框,看截图:
5。 然后点击 OK 关闭对话框,现在按 F5 键运行此代码,并弹出一个提示框,请输入要删除的附件类型,请参阅屏幕截图:
6。 点击 OK,并且所有具有您定义的特定类型的附件都被立即删除,请参阅截图:
Kutools for Outlook
超过100高级功能的Outlook 2010,2013,2016,2019和365
更多功能 | 免费下载 | 只有$ 39.00数百个函数
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment...
The comment will be refreshed after 00:00.
Be the first to comment.