Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2023, 03:14 AM
gmayor's Avatar
gmayor gmayor is offline Rename attachment in draft email Windows 10 Rename attachment in draft email Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #2  
Old 01-29-2023, 04:37 PM
JamesMWood JamesMWood is offline Rename attachment in draft email Windows 10 Rename attachment in draft email Office 2021
Novice
Rename attachment in draft email
 
Join Date: May 2022
Posts: 25
JamesMWood is on a distinguished road
Talking

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!
Reply With Quote
Reply

Tags
attachments, rename



Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename attachment in draft email Rename attachment based on attachment name AndyDDUK Outlook 1 03-01-2017 07:32 AM
Rename attachment based on attachment name AndyDDUK Outlook 1 03-01-2017 07:31 AM
Rename attachment in draft email Rename docm to value from checkbox, convert to .pdf, email, delete 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
Rename attachment in draft email email as pdf attachment - subject line and attachment named after mail merge Nexus Mail Merge 12 04-13-2011 11:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft