MaxLauncher and sending HTML emails via script
In the previous article MaxLauncher & sending emails in Thunderbird with mailto: I used my default email application to setup a new Template to send emails.
I was able to add a few signatures to in the body of the text so that I could just delete the ones I didn’t want. As well as a note for Attachment if there was one, again, if not required then I’d delete that line.
After all its easier to delete than to write out fully.
The nice thing with the Mailto: approach is that you can use Emojis in the Subject line to make the Topic stand out when sending to others (just remember to save the .ahk script file in encoded UTF-8_BOM instead of the UTF-8 encoding)

So the template can be setup for a few variations but in it it has :
- FROM (my preferred email to send FROM
- TO prefilled, I can have a couple of Templates for different people I regularly email to & can add CC & BCC if I want
- In SUBJECT Emoji icons to make email stand out in recipients inbox
- Start the Body with Dear for standard greeting
- A note for Attach, this triggers Thunderbird to look for attachment & add yellow highlight bar at bottom
- A few different simple signatures, I’m personally not keen on images in signatures as they bloat the mail files, so I personally don’t use them. I also have hotkeys to put these in for me if I want.
So this meets most of my requirements, apart from being able to put HTML into the body of the text as a signature automatically with the mailto: process
[email protected]
em2= [email protected]
em3= [email protected]
Subj= ?️the tree is green
Bod= The message's first paragraph.`%0ASecond paragraph.`%0AThird Paragraph`%0
Run, mailto:%em1%?cc=%em2%&cc=%em3%&bcc=%em3%&subject=%Subj%&body=%Bod%
Return
HTML in Emails & sending via scripts
So I have the mailto template that I can use with MaxLauncher with Thunderbird , but my formasl signature is a bit of html code with buttons and lots of colours. So I’d like to be able to add HTML.
I came across 2 videos, one by Joe Glines and one by Juho Lee, see below, that allowed you to pre-set up your email and then send it programmatically via running a script.
I tried both scripts, they have some added features over the mailto: process in previous article, these are:
- You can preset all the addresses
- You can add attachments
- You can write HTML in the body of the text
- You can have multiple main people to email to (I haven’t been able to get this to work with mailto: but apparently it can be done)
Negatives
- Cannot put emojis into Subject header
- you need to setup your password so that it can be fed into the script
- The HTML inside the script can be a bit unwieldy- see this article (https://www.reddit.com/r/AutoHotkey/comments/45eed1/automating_an_html_outlook_email_with_autohotkey/)
I am happy to accept some of the challenges of the negatives apart from The emoji in the SUBJECT title, it’s a fad I’m going through and I like using it. So for the time being
I used my gmail address to run the scripts from and adjusted my gmail account to allow this to work.
A couple of things with the 2 scripts:
In Juhos it gives a pop-up box for you to enter your password in before sending the email. A good idea apart from having to hit the OK button prior to sending, one step too many
In the Glines script it works on the password being in an ini file that it reads, so you can locate the ini file in another location. I like this method better as once its setup you don’t have to think about it.
Reading another file for input information
I’m wondering if it might be possible to have a separate file with the data for the email so the script just reads that instead.
The reason I say that is, when I was doing my HTML signature trying to sendInput all the information it took ages to type it out at the bottom of the email. I ended up just putting it in a file and calling that file, that method was really fast.
Following on from that, maybe a Pop-up GUI with input fields so that you can add all your requirements into input fields (starting to develop into an email program.
Maybe there could just be some preset HTML stuff, top and bottom of page and then just straight text in the middle, so preset stuff fired in from a file and then add the normal text in later.
Final script
#SingleInstance,Force ;run only once
;+++++SET PAUSE TIME VAR++++++++++
timeS=1000 ;pause time between actions
;+++++SET EMAIL ADDRESSES++++++++++ see RULES above
em1= [email protected] ;TO
em2= ;CC
em3= ;CC & BCC
Subj= ? ; This emoji default for window search Winactivate
Bod= Dear ; Text Body (Plain Text)
Run, mailto:%em1%?cc=%em2%&cc=%em3%&bcc=%em3%&subject=%Subj%&body=%Bod%
FileRead, OutputVar, E-fullSignature.txt
; sleep, 500
clipboard := "" ; Give the clipboard entirely new contents.
clipboard := OutputVar ; Empty the clipboard.
WinActivate, Write: ? - Thunderbird
sleep, 2000 ;%timeS%
send, !I
sleep, %timeS%
send, {Down 5}
sleep, %timeS%
send, {Enter}
sleep, %timeS%
send, ^v
send, {Tab}
send, {Enter}
Return
End comment
Overall I’ll stick with the mailto method, I can always add my HTML signature in by Hotkeys as I can have emojis in the SUBJECT line.
If I’m doing mass send-outs or want to automate the task I’ll look at using the Glines method , purely from the point of the password being setup once. I think the scripts are pretty similar apart from that.
The attachments is a handy feature too.
In the last segment I was thinking about some alternative methods for body text but the question is how much effort to put into this? Is it worth the returns or is it just for occasional use?