![]() |
|
#1
|
||||
|
||||
![]()
The following should work.
Code:
Sub ReAttach() Dim olItem As MailItem Dim olAtt As Attachment Dim sName As String Dim sPath As String Dim cNames As Collection Dim i As Long sPath = Environ("TEMP") & "\" On Error Resume Next Select Case Outlook.Application.ActiveWindow.Class Case olInspector Set olItem = ActiveInspector.currentItem Case olExplorer Set olItem = Application.ActiveExplorer.Selection.Item(1) End Select olItem.Save Set cNames = New Collection If olItem.Attachments.Count > 0 Then For i = olItem.Attachments.Count To 1 Step -1 Set olAtt = olItem.Attachments(i) sName = olAtt.FileName If Not sName Like "image*.jpg" Then sName = Replace(olAtt.FileName, "%20", " ") olAtt.SaveAsFile sPath & sName cNames.Add sPath & sName olAtt.Delete End If Next i For i = 0 To cNames.Count 'Debug.Print cNames(i) olItem.Attachments.Add cNames(i) Kill cNames(i) Next i End If lbl_Exit: Set olItem = Nothing Set olAtt = Nothing Set cNames = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#2
|
|||
|
|||
![]()
You're an absolute genius. Thank you so, so much. This has been driving me mad, and I really am trying to learn. Thanks a lot!
![]() |
![]() |
Tags |
attachments, rename |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
AndyDDUK | Outlook | 1 | 03-01-2017 07:32 AM |
Rename attachment based on attachment name | AndyDDUK | Outlook | 1 | 03-01-2017 07:31 AM |
![]() |
Lortiz70 | Word VBA | 1 | 01-19-2017 02:48 AM |
Email sends mailmerge file behind email rather than attachment | TLC1974 | Mail Merge | 2 | 07-22-2016 12:53 AM |
![]() |
Nexus | Mail Merge | 12 | 04-13-2011 11:34 PM |