How to send email in sql server without configuring database mail

Rakesh kumar 106 Reputation points
2020-10-05T18:09:28.787+00:00

I'm capturing Error log table in SQL SERVER.Actually My task is when error raised in try/ catch block should be send a email to my inbox and is any possible without setting any configuring database mail and any writing SP and giving directly port numbers and mail id is possible?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,948 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,651 questions
{count} votes

Accepted answer
  1. Tom Phillips 17,736 Reputation points
    2020-10-05T18:48:16.677+00:00

    You should write the error to an error log, and then use an SSIS job running from SQL Agent to send them to email.


2 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 112.6K Reputation points MVP
    2020-10-05T21:28:12.28+00:00

    I guess you could write a CLR procedure for the task. BUT DON'T DO IT!

    Exception handlers should be simple. The last thing you want is an exception handler that fails, because then you lose the original error message, and you have no idea what the problem is. Sending mail from an error handler is definitely too complex.

    And I predict that if you would actually get it going, you would grew tired of those mail pretty quick.

    0 comments No comments

  2. Tom Phillips 17,736 Reputation points
    2020-10-08T13:52:00.543+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.