我经常收到带有30+附件的电子邮件,里面嵌有PDF文件。我需要一个VBA代码,将所有嵌套的PDF文件复制到Outlook外的文件夹中。有人能给我指个方向吗?
示例:
Main Email
Attached email
PDF attachment
Attached email
PDF attachment
Attached email
PDF attachment
Attached email
PDF attachment
Etc...如何一次操作将所有嵌套的PDF复制到outlook外部的文件夹?
提前感谢您的指点。
发布于 2019-03-28 07:09:15
Outlook不允许您直接访问嵌入的邮件附件-您需要首先使用Attachment.SaveAsFile保存它们,然后使用Namespace.OpenSharedItem打开邮件文件。
如果使用Redemption是一个选项(我是它的作者),它将公开RDOAttachment.EmbeddedMsg属性,该属性将嵌入式邮件附件作为RDOMail对象返回:
set OutlookMsg = Application.ActiveExplorer.Selection(1)
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set msg = Session.GetRDOObjectFromOutlookObject(OutlookMsg)
ProcessMessage(msg)
sub ProcessMessage(msg)
for each attach in msg.Attachments
if attach.Type = olEmbeddedItem Then
ProcessMessage(attach.EmbeddedMsg)
elseif attach.Type = olByValue Then
attach.SaveAsFile "c:\temp\" & attach.FileName
End If
next
end subhttps://stackoverflow.com/questions/55386914
复制相似问题