所以我有一个sql存储过程:
CREATE PROC sp_SendConfirmedPurchasesEMail
(
@RecID INT
)
AS
...
msdb.dbo.sp_send_dbmail
@profile_name = @ProfileName,
@recipients = @MailRecipients,
@body = @MsgBody,
@subject = @MailSubject,
@body_format = @BodyFormat,
@importance = @MsgImportance,
@sensitivity = @MsgSensitivity,
@file_attachments = 'Some File That Doesnt Exist',
@query = @DBQuery,
@execute_query_database = @ExecuteQueryDatabase,
@attach_query_result_as_file = @AttachQueryResultAsFile,
@query_attachment_filename = @QueryAttachmentFilename,
@query_result_header = @QueryResultHeader,
@query_result_width = @QueryResultWidth,
@query_result_separator = @QueryResultSeparator,
@exclude_query_output = @ExcludeQueryOutput,
@append_query_error = @AppendQueryError,
@query_no_truncate = @QueryNoTruncate,
@copy_recipients = @CC,
@blind_copy_recipients = @BCC,
@reply_to = @ReplyTo,
@from_address = @FromAddress
END
我在SSMS中运行时遇到错误:
Msg 22051, Level 16, State 1, Line 0
Attachment file <MyFileGoesHere> is invalid.
我无法弄清楚为什么如果我将TRY / CATCH放在“sp_send_dbmail”的调用周围,我的捕获中没有错误?