Good morning, I'm trying to automate a process and it all starts when a robot sends me 8 emails with a csv file attached. I have searched the internet and I have found code in VBA to create a rule in Outlook and be able to download the csv automatically when the mail arrives.
The VBA code I used to do this is as follows:
Public Sub saveAttachtoDisk2(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "J:\xx\xx\xxxx\xxx\xx\xxx\2. Correcciones\"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & objAtt.FileName
Set objAtt = Nothing
Next
End Sub
What I want is that I save the files in a specific path and that I only download the csv, right now it downloads the csv and 2 photos (.png) that it takes from the email signature. I don't have much idea about VBA, does anyone know how I can limit the code so that it only downloads csv files?
And another question I have is that when I do tests and send many emails in a row, it gives me the following error "the error -2147024894 has occurred at runtime, the attachments cannot be saved" and I don't know what could be the cause , since when they send me an email, 30 seconds go by and they send me another, it doesn't give me an error, but if they send them to me en masse, yes.
Does anyone know why this could be happening?