繁体   English   中英

Outlook VBA 代码从电子邮件中提取附件并将它们保存到 Outlook 中的单独文件夹中

[英]Outlook VBA code to extract attachment from emails and save them to a separate folder in Outlook

请如果有人可以提供帮助,那就太好了,我需要创建一个宏,使我能够从标题中带有“X”的选定电子邮件中提取附件(Outlook 电子邮件)。 然后我需要将这些附件保存到 outlook 内的文件夹中。 这可能吗? 任何建议将不胜感激!

使用Attachment.SaveAsFile方法将附件保存到指定路径。

从标题中带有“X”的选定电子邮件中提取附件(Outlook 电子邮件)。

目前尚不清楚 Outlook 中的标题代表什么,但我想您是在谈论Subject行。 Explorer.Selection属性返回一个Selection object,其中包含在资源管理器 window 中选择的一个或多个项目。 例如,以下是在 Explorer window 中获取所选项目的方法:

Sub GetSelectedItems() 
 Dim myOlExp As Outlook.Explorer 
 Dim myOlSel As Outlook.Selection
 Dim mySender As Outlook.AddressEntry 
 Dim oMail As Outlook.MailItem 
 
 Dim x As Long 
 
 Set myOlExp = Application.ActiveExplorer  
 Set myOlSel = myOlExp.Selection  
 For x = 1 To myOlSel.Count  
   If InStr(1, myOlSel.Item(x).Subject, "X") <> 0 Then  
     Set oMail = myOlSel.Item(x)    
   End If  
 Next x 
 
End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM