問題描述
Không gửi được tệp nhật ký bằng 'Tác vụ Gửi Thư' từ trình xử lý OnError (Sending the log file using a 'Send Mail Task' from the OnError handler fails)
I have a package which is configured to create a log file. When an error occurs, I want the OnError event handler for the package to send an email with the log file as an attachement. This fails with the message:
Either the file "C:\Log\blablabla.txt" does not exist or you do not have permissions to access the file.
The file does exist, so the problem must be that I do not have permissions to access it. The package is able to create the file so does this mean the file cannot be accessed because the package is still executing (and therefore writing to the file)?
Configuration: SQL‑Server 2005. Property DelayValidation == True.
Edit: I have stumbled across a solution for this problem. It is not enough to set DelayValidation of the task itself to True. You must also set it for the Event Handler (OnError in this case) that contains the task. Doing the same thing for a Send Mail Task that is executed when the package succeeds (so from within Control Flow) still produces the same error.
參考解法
方法 1:
For sending attachments through send email task you should have sysadmin permission.
(by Captain Sensible、Maximus)