Return Code Values Documentation for sp_send_dbmail procedure

I saw a question on MSDN forums today about return code values documentation for sp_send_dbmail procedure. Microsoft has not documented these return values to the user because when an error exists in the code the user will get a clear description about the error which is easy to understand hence they have provided only description for 0 (failure) and 1 (success). I’ll provide the list of return values and their description here, I’m sharing this since some of the developers will read this value and they can make use of it to get the reason for failure.

Return Value

Error Number returned to user

Description

0 NA Success
1 Will provide the below error number based on the failure Failure
2 14618 Attach results must be specified
3 14618 No output must be specified
4 14618 No header must be specified
5 14618 Check if query_result_separator is specified
6 14618 Echo error must be specified
13 14626 @body_format can be TEXT (default) or HTML
15 14618 Importance must be specified
16 14622 Importance must be one of the predefined values
17 14618 Sensitivity must be specified
18 14623 Sensitivity must be one of predefined values
19 14624 Message body cannot be null. At least one of message, subject, query,attachments must be specified.
20 14624 Recipients cannot be empty. At least one of the To, Cc, Bcc must be specified
21 14625 If query is not specified, attach results and no header cannot be true.
VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.13_1145]
Rating: +3 (from 3 votes)

Comments are closed.