basicintern
07-01-2014, 10:44 AM
I am using a Dir() function to loop through files in a folder and attach them to an Outlook email:
report_file = Dir(report_path & folder1)
Do While Len(report_file) > 0
.Attachments.Add report_file
report_file = Dir
Loop
The Dir() function is finding the first file in the folder and correctly saving it to the report_file variable but I get the following error once I try to attach it: "Cannot find this file. Verify the path and file names are correct." The path and file names must be correct since the code found the file itself using the path name. But then it suddenly can't find the file anymore once it's time to attach it. I tried both moving this folder to a local drive and erasing the folder and recreating it entirely but neither worked. I am so lost!
report_file = Dir(report_path & folder1)
Do While Len(report_file) > 0
.Attachments.Add report_file
report_file = Dir
Loop
The Dir() function is finding the first file in the folder and correctly saving it to the report_file variable but I get the following error once I try to attach it: "Cannot find this file. Verify the path and file names are correct." The path and file names must be correct since the code found the file itself using the path name. But then it suddenly can't find the file anymore once it's time to attach it. I tried both moving this folder to a local drive and erasing the folder and recreating it entirely but neither worked. I am so lost!