I am using html email and .format() for string to pass in the arguments
Below are my python code :
import sys
try:
print(5 / 0)
except Exception as e:
send_error_email(exp_message=format_exc())
and then fetching the function send_error_email and pass to MIMEMultipart mail script
html = """
<html>
<body>
<b> Exception Details: </b> {exp_message}
</body>
</html>
""".format(exp_message=exp_message)
Getting Output in one line in mail :
Exception Data : Traceback (most recent call last): File "C:\Build\test\workfile\python-practice\exception_test.py", line 54, in get_details print(100/0) ZeroDivisionError: division by zero
Expected Output should be every message in new line:
Exception Data : Traceback (most recent call last):
File "C:\Build\test\workfile\python-practice\exception_test.py", line 54,
in get_details print(100/0)
ZeroDivisionError: integer division or modulo by zero
'.join(format_exc().splitlines())) – ansh1 Oct 20 '21 at 08:12