# Send Email on Build Failure

**URL:** <https://www.finalbuilder.com/forums/t/send-email-on-build-failure/7422>\
**Category:** Discussion\
**Created:** [November 15, 2023, 3:48pm UTC](https://www.finalbuilder.com/forums/t/send-email-on-build-failure/7422 "2023-11-15T15:48:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MCone](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/mcone/32/2779_2.png) [@MCone](https://www.finalbuilder.com/forums/u/MCone)\
**Post date:** [November 15, 2023, 3:48pm UTC](https://www.finalbuilder.com/forums/t/send-email-on-build-failure/7422/1 "2023-11-15T15:48:42Z")

</div>

The email SMTP feature works great. I am sending the HTML log to the entire team if the build finishes.

Now I am trying to figure out how to send an email if the build fails. I know that Final Builder can do this - but I cannot seem to find a sample of how.

Can someone please show me how to do this?

---

<div class="post-metadata">

**Author:** ![MCone](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/mcone/32/2779_2.png) [@MCone](https://www.finalbuilder.com/forums/u/MCone)\
**Post date:** [November 15, 2023, 6:29pm UTC](https://www.finalbuilder.com/forums/t/send-email-on-build-failure/7422/3 "2023-11-15T18:29:02Z")

</div>

I found the solution. It is to use the Try-Catch-End logic like this:

![TryCatchEnd](https://www.finalbuilder.com/forums/uploads/default/original/2X/e/e2871797a27fdc13ca32e207adfa2d51ce109485.png)

Enable or disable the Raise Exception action to test the Try-Catch logic.

In my FinalBuilder code, I send an email at the end of both Try-Catch sections with the FB HTML log attached. Finalbuilder then sends outgoing emails for both success and failure. If I have no email, then  
I can be pretty confident that FinalBuilder is still running.

[TryCatchEndSample.fbp8](https://www.finalbuilder.com/forums/uploads/short-url/6JHKnTazrBpwHCUTVXHgLrs6UDD.fbp8) (5.4 KB)

---

<div class="post-metadata">

**Author:** ![Marc827](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@Marc827](https://www.finalbuilder.com/forums/u/Marc827)\
**Post date:** [March 13, 2024, 10:04pm UTC](https://www.finalbuilder.com/forums/t/send-email-on-build-failure/7422/4 "2024-03-13T22:04:10Z")

</div>

That works as long as the FinalBuilder task wasn’t terminated. Things like Visual Studio crashes can hang the process as well - Microsoft can launch error modal dialogs that require user intervention to unfreeze it.

---

<div class="post-metadata">

**Author:** ![MCone](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/mcone/32/2779_2.png) [@MCone](https://www.finalbuilder.com/forums/u/MCone)\
**Post date:** [April 12, 2024, 3:20pm UTC](https://www.finalbuilder.com/forums/t/send-email-on-build-failure/7422/5 "2024-04-12T15:20:21Z")

</div>

Good point. Fortunately, I use the Delphi command line from inside FinalBuilder - which never requires modal interaction to unfreeze. It works exactly like I hoped it would without a problem.
