I need to send email via command-line without any human interactions for automation.
I know we can use mailto command but that would compose email, subject,body and everything but it wouldn't send it unless I click send.
I read online we can use blat but I cannot use anything other than outlook.
This is closed post I have found Link to SOF post.
just for your information: I am looking into some telnet commands to send email haven't gotten success in that yet either.
telnet commands to send email
Best Answer
Option 1
You didn't say much about your environment, but assuming you have it available you could use a PowerShell script; one example is here. The essence of this is:
You could then launch the script from the command line as per this example:
Note that PowerShell 2.0, which is installed by default on Windows 7 and Windows Server 2008R2, includes a simpler
Send-MailMessage
command, making things easier.Option 2
If you're prepared to use third-party software, an option is something like this SendEmail command-line tool. It depends on your target environment, though; if you're deploying your batch file to multiple machines, that will obviously require inclusion (but not formal installation) each time.
Option 3
You could drive Outlook directly from a VBA script, which in turn you would trigger from a batch file; this would let you send an email using Outlook itself, which looks to be closest to what you're wanting. There are two parts to this; first, figure out the VBA scripting required to send an email. There are lots of examples for this online, including from Microsoft here. Essence of this is:
Then, launch Outlook from the command line with the
/autorun
parameter, as per this answer (alter path/macroname as necessary):Option 4
You could use the same approach as option 3, but move the Outlook VBA into a PowerShell script (which you would run from a command line). Example here. This is probably the tidiest solution, IMO.