How to save Outlook attachment in a drive with a new name and overwrite if it already exists? I am using below VBA script to download attachments from email and save it to my windows directory.
I need help to modify this script - 1) to save rename the attachment before saving it 2) Overwrite the file if it already exists. Kindly help.
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = &quot;F:\RBL Attachments\&quot;
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder &amp; oAttachment.DisplayName
Next
End Sub
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim obj As Outlook.Attachment
Dim saveFolder As String
saveFolder = &quot;D:\EmailAttachments&quot;
     For Each obj In itm.Attachments
          obj.SaveAsFile saveFolder &amp; &quot;\&quot; &amp; obj.DisplayName
          Set obj = Nothing
     Next
End Sub