Delete/replace old files and save new attachments

Status
Not open for further replies.

BillA83

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
I receive 5 emails twice a week, on Monday and Thursday. Each email contains a single .csv file attached. Each .csv file has a different name and ends with the same date in which the attachment was generated e.g. "Report1_2016-09-29.csv," "Report2_2016-09-29.csv," etc...

Presently I have an Outlook rule that identifies the received email using standardized subject line, and containing an attachment. The rule runs a script that takes the attachment and places it in a network folder.

I would like to delete (or replace) older files as new emailed attachments are received, but I haven't had any luck with the proper code. This is what I use presently to transfer the attachments to the networked folder:

Public Sub saveAttachtoDisk (itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
SaveFolder = "\\folder\sub_folder\"
For Each objAtt in itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub

We are on Windows 7, running Office/Outlook Pro 2010. I would appreciate suggestions.

Thank you in advance.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Status
Not open for further replies.
Top