|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
网上找的代码,不知道楼主的是不是以下这个。原理很简单,F8运行一下会发现正文中的图片都是以“imageXXX”的名称命名的如“image001”,那么只要把名称前缀是这个的剔除即可。
接下来就简单了,在copy里面增加一个if判断剔除不要的正文的图片剩下的就是我们要的附件啦。
- '带附件回复
- Sub ReplyWithAttachments()
- Dim rpl As Outlook.MailItem
- Dim itm As Object
- Set itm = GetCurrentItem()
- If Not itm Is Nothing Then
- Set rpl = itm.Reply
- CopyAttachments itm, rpl
- rpl.Display
- End If
- Set rpl = Nothing
- Set itm = Nothing
- End Sub
- '带附件回复所有
- Sub ReplyToAllWithAttachments()
- Dim rpl As Outlook.MailItem
- Dim itm As Object
- Set itm = GetCurrentItem()
- If Not itm Is Nothing Then
- Set rpl = itm.ReplyAll
- CopyAttachments itm, rpl
- rpl.Display
- End If
- Set rpl = Nothing
- Set itm = Nothing
- End Sub
- '获取主题名称
- Function GetCurrentItem() As Object
- Dim objApp As Outlook.Application
- Set objApp = Application
- On Error Resume Next
- Select Case TypeName(objApp.ActiveWindow)
- Case "Explorer"
- Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) '获取主题名称
- Case "Inspector"
- Set GetCurrentItem = objApp.ActiveInspector.CurrentItem '获取主题名称
- End Select
- Set objApp = Nothing
- End Function
- '复制附件
- Sub CopyAttachments(objSourceItem, objTargetItem)
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
- strPath = fldTemp.Path & ""
- For Each objAtt In objSourceItem.Attachments
- <font color="#ff0000">If Left(objAtt, 5) = "image" Then
- GoTo down</font>
- <font color="#ff0000">Else</font>
- strFile = strPath & objAtt.FileName
- objAtt.SaveAsFile strFile
- objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
- fso.DeleteFile strFile
- <font color="#ff0000">End If
- down:</font>
- Next
- Set fldTemp = Nothing
- Set fso = Nothing
- End Sub
复制代码
|
|