I should point out that the above code which uses WINSOCK does not support SSL, but the email server I am using does not use SSL so it works for me.
I also tried using PowerShell/Windows Scripting Host (WSH). That also works and provides SSL if you need it. I tested it on GMAIL servers, but we have our own email server. It may not work on older Windows version though. My test system is Windows 10, but our
server is actually an old machine so PowerShell does not work on it.
I can't seem to find where I got the source code from, but there is discussion about it here: