Rename attachment based on attachment name
Hi
I've receive multiple attachments on an email.
Some of these contain a date in the file name.
What is the code to modify the below, to take eg the first 5 characters in the file name?
Eg to save an attachment with a file name of "ABCDE_01032017.xls" as "ABCDE.xls" ?
Public Sub Save_APPS(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "P:\Data\"
For Each objAtt In itm.Attachments
If InStr(objAtt.DisplayName, ".xls") Then
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
End If
Set objAtt = Nothing
Next
End Sub
May thanks
Andy
|