I found the official docs to be lacking while trying to build a template email. This script demonstrates everything I feel could be better explained, hopefully it can help you learn too.
- Embedding images (official example was nonsense)
- Attaching a file (not reliable with Thunderbird)
- Saving the email as a file to be opened in an email client
The original script worked great on Windows 7 with Outlook. I've made some tweaks so it mostly works with Thunderbird too if the X-Unsent support addon is installed.