什么是从一个批处理文件发送电子邮件的最好方法? [英] What is the best way to send an email from a batch file?

查看:162
本文介绍了什么是从一个批处理文件发送电子邮件的最好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个夜间批处理作业,它可以告诉如果它失败了。我希望它给我一个电子邮件,可能与当它的附件。

I have a nightly batch job that can tell if it has failed. I want it to send me an email, possibly with an attachment when it does.

我如何从一个Windows批处理文件(.bat)?

How can I send an email from a Windows Batch (.bat) file?

推荐答案

如果在SMTP服务器是安装了IIS的一部分,你可以使用echo命令将文件写入到拾取文件夹,它会被发送。

If the SMTP-server that is a part of IIS is installed, you could use the Echo command to write a file to the pickup folder, and it'll get sent.

echo From: test@example.com>tmp.txt
echo To: test@example.com>>tmp.txt
echo Subject: hello>>tmp.txt
echo.>>tmp.txt
echo Hello world>>tmp.txt
copy tmp.txt \Inetpub\mailroot\Pickup

这篇关于什么是从一个批处理文件发送电子邮件的最好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆