A good option is to use VS Code. A simple Ctrl C and Ctrl V will grab the code along with highlighting and your editor theme (In my case dark). You'll get something like:
Code sent via email with dark mode with highlighting
Another option is a Chrome extension called Markdown Here which supports GitHub flavored markdown. Using the extension, here is what I achieved by enclosing Python code with ```Python (some code)``` Code sent via email highlighted using Markdown Here.
I find the Vs code version more good looking though. Happy highlighting!
Ps: Usually to highlight code we enclose it in three backticks (```) and if you want the code highlighted in a certain language syntax you write the name of the language after the opening backticks then the code and finally the closing set. An example with Python would be opening backticks, the word 'Python', the code then closing backticks. You will end up with something like:
print is True
if print is True:
print('sample python code')
else:
pass