Your applications may generate reports and log files every day. And you may get asked by managers is "couldn't you just email that report to me?"
The most popular email client in Windows is Microsoft Outlook, however, it does not support command line.
Can I send email just through command line in Windows? If so, I can send email by batch file, and the email can be sent by schedule task.
This How-To describes using CmdEmail Pro and a gmail/hostmail account to extend the automatic generation of reports and send the reports and any files to your manager.
1. Download CmdEmail Pro from this link:
2. CmdEmail Pro Edition Usage
Command Line Send Email Component (version 2.6)
Usage: sendmail [-to:
-to:<recipients> Specify the recipients
-m:<file path> Specify the file contains message to be sent
-user:<user name> Specify the user name used to login SMTP server
-pwd:<password> Specify the password used to login SMTP server
-a:<file path> Specify the file to be attached with the mail
-compress Compress the attachments.
-zippwd:<password> Specify password used to protect the zip file.
-subject:<subject> Specify the subject.
-body:<the body> Specify the message body.
-html Send mail in html format.
-firstline:<first line> Insert the first line before body.
-setup Change email account settings etc.
3. Setup your email account.
Before send email, you should have an email account. In this article, we use the free Gmail account. You are better off using your own business email account, and the smtp server is owned by your company.
Please run sendmail.exe -setup
Fill in account information and click OK.
Your Name: Name of sender
Email Address: Email address of sender
Outgoing SMTP Server: Name or IP address of the SMTP server. For example: smtp.live.com
Server requires authentication: check it in most case, because most smtp server requires authentication.
SSL/TLS enabled: Instructs the program to send the email using SSL. Using the ssl switch can often solve problems where the server expects a STARTTLS command.
User Name and password: User name and password used for authentication. The pasword will be encrypted and saved to file system.
4. Run command line to send email.
sendmail.exe -to:email@example.com -subject:"test message" –a:c:\path\report.txt
Compress the attachment
Please append -compress to the command line, the CmdEmail will compress the attachment before send it.
Specify more parameters
In case you want to specify more parameters, for example, send copy to other recipients, please create a message file, and pass the path of the file by command line.
There is a empty line between header and body. The following is an example:
First line of the body.
Save the text above to C:\temp_name.txt . Run CmdEmail again, e.g.
CmdEmail will read information from the message file, then send a mail to firstname.lastname@example.org, copy to email@example.com .
Send rich format email
Please append -html to the command line. To get more information please view the document of CmdEmail.