标题: [文本处理] 批处理如何将txt文本内容输出到cmd命令行中? [打印本页]
作者: lxfka 时间: 2013-8-13 12:03 标题: 批处理如何将txt文本内容输出到cmd命令行中?
因为小弟想通过批处理命令行发送邮件,但是邮件的内容想从txt文档或者log文档中导入到cmd命令行中,请大神帮助实现啊,在线等谢谢!- @echo off
- @del temp.vbs
- @echo on error resume next >>temp.vbs
- @echo dim WshShell,txt>>temp.vbs
- @echo Set WshShell = WScript.CreateObject("WScript.Shell")>>temp.vbs
- @echo WshShell.run"cmd">>temp.vbs
- @echo WshShell.AppActivate"c:\windows\system32\cmd.exe">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"telnet smtp.163.com 25{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"helo localhost{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"auth login{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"name{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"password{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"mail from : <xxxx@163.com>{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"rcpt to : <xxxxx@qq.com>{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"data{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"subject : test{ENTER}{ENTER}">>temp.vbs
- @echo WScript.Sleep 200>>temp.vbs
- @echo WshShell.SendKeys"test from myself {ENTER}">>temp.vbs
- @echo WshShell.SendKeys".{ENTER}">>temp.vbs
- @call temp.vbs
复制代码
作者: apang 时间: 2013-8-13 19:23
发送c:\a.txt 文本内容,试试看吧:- @echo off
- del temp.vbs
- (
- echo on error resume next
- echo dim WshShell,fso,str
- echo set fso = createobject^("scripting.filesystemobject"^)
- echo str = fso.opentextfile^("c:\a.txt"^).readall
- echo Set WshShell = WScript.CreateObject^("WScript.Shell"^)
- echo WshShell.run"cmd"
- echo WshShell.AppActivate"c:\windows\system32\cmd.exe"
- echo WScript.Sleep 200
- echo WshShell.SendKeys"telnet smtp.163.com 25{ENTER}"
- echo WScript.Sleep 200
- echo WshShell.SendKeys"helo localhost{ENTER}"
- echo WScript.Sleep 200
- echo WshShell.SendKeys"auth login{ENTER}"
- echo WScript.Sleep 200
- echo WshShell.SendKeys"name{ENTER}" 'base64加密后的用户名
- echo WScript.Sleep 200
- echo WshShell.SendKeys"password{ENTER}" 'base64加密后的密码
- echo WScript.Sleep 200
- echo WshShell.SendKeys"mail from : <xxx@163.com>{ENTER}"
- echo WScript.Sleep 200
- echo WshShell.SendKeys"rcpt to : <xxx@qq.com>{ENTER}"
- echo WScript.Sleep 200
- echo WshShell.SendKeys"data{ENTER}"
- echo WScript.Sleep 200
- echo WshShell.SendKeys"subject : test{ENTER}{ENTER}"
- echo WScript.Sleep 200
- echo WshShell.SendKeys str ^& "{ENTER}"
- echo WshShell.SendKeys".{ENTER}"
- )>temp.vbs
- call temp.vbs
复制代码
作者: lxfka 时间: 2013-8-13 21:22
回复 2# apang
真的非常感谢,试了一下完全OK
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |