Batch file for shoot mail
A batch file for sending an email!
Here's an example batch file that sends an email using the wmic
command and the mailto
protocol:
@echo off
:: Set the email recipient and subject
set [email protected]
set subject=Test Email from Batch File
:: Set the email body
set body=This is a test email sent from a batch file.
:: Send the email
wmic path win32_process call create "mailto:%recipient%?subject=%subject%&body=%body%"
Let me explain what each line does:
@echo off
: This line turns off the command echoing, which means that only the final output will be displayed in the command prompt.set [email protected]
: This line sets the email recipient's address.set subject=Test Email from Batch File
: This line sets the email subject.set body=This is a test email sent from a batch file.
: This line sets the email body.wmic path win32_process call create "mailto:%recipient%?subject=%subject%&body=%body%"
: This line uses thewmic
command to create a new process that sends an email using themailto
protocol. The%recipient%
,%subject%
, and%body%
variables are replaced with the actual values set earlier.
To use this batch file, simply save it with a .bat
extension (e.g., send_email.bat
) and run it in the Command Prompt or double-click it to run it.
Note: This batch file uses the wmic
command, which is a built-in Windows utility. However, the mailto
protocol may not work if your email client is not configured to handle it. Additionally, this batch file does not include any error handling or logging, so you may want to add those features depending on your specific use case.