Before even writing code:
- drop the Excel file format, xls is very old > 10 years and not used anymore.
- drop the proc import, this guesses the data and will be the source of many headaches for you continuing to use it.
Next, define the process:
- Get csv file
- Datastep import CSV
- Using the error automatic variable of the datastep check:
if _ERROR_ then call execute('%Send_Email();');
- Have a macro for sending the email.