Windows下通过脚本自动发邮件

简介:

创建一个脚本文件,名字随意,扩展名vbs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
subject=WScript.Arguments(0)
content=WScript.Arguments(1)
 
set sh=WScript.CreateObject( "WScript.Shell" )
host=WScript.FullName
 
If  LCase(Right(host,11))= "wscript.exe"  Then
     sh.run  "cscript //nologo " ""  & WScript.ScriptFullName & Chr(34), 0
     WSCript.Quit
End  If
 
sh.Run  "cmd.exe"
WScript.Sleep 1000
sh.SendKeys  "telnet"
sh.SendKeys( "{Enter}" )
WScript.Sleep 1000
sh.SendKeys  "open smtp.somesome.com 25" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 1000
sh.SendKeys  "helo somesome.com" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 500
sh.SendKeys  "auth login" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 500
sh.SendKeys  "xxxxxxx" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "xxxxxxx" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "mail from:<test1@somesome.com>" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 500
sh.SendKeys  "rcpt to:<test1@somesome.com>" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "rcpt to:<test2@qq.com>" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "data" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "from:test1" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "to:test2" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "subject:"  & subject 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys content 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys  "." 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys( "{Enter}" )
WScript.Sleep 1000
sh.SendKeys  "quit" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 5000
sh.SendKeys( "{Enter}" )
WScript.Sleep 2000
sh.SendKeys  "quit" 
sh.SendKeys( "{Enter}" )
WScript.Sleep 100
sh.SendKeys( "exit{Enter}" )
 
WScript.Quit

启动脚本,传入参数:

1
cscript //Nologo SendMail3.vbs subject-%time% content111

本文转自   zl1030   51CTO博客,原文链接:http://blog.51cto.com/zl1030/1926402
相关文章
|
1月前
|
运维 监控 关系型数据库
运维实战:Windows服务挂掉了怎么办,通过Bat脚本实现自动重启
本文介绍了如何使用Bat脚本自动监控并重启Windows服务器上的挂掉服务,例如MySQL,以避免在假期等情况下需要紧急处理问题。首先,创建一个Bat脚本,设定每小时检查一次服务状态,如果服务停止则自动重启。脚本内容包括检查服务是否运行并根据状态执行相应操作。同时,脚本中包含了确保以管理员权限运行的代码。 脚本需设置为ANSI编码以防止乱码。推荐将Bat脚本封装为Windows服务以保证稳定运行,提供了使用NSSM工具、Windows服务程序和开源的Java工具winsw将批处理脚本转化为服务的方法。这些方法可以确保服务在后台可靠运行,即使在服务意外停止时也能自动恢复。
|
29天前
|
关系型数据库 MySQL 数据安全/隐私保护
windows系统bat批处理 mysql 脚本启动关闭
windows系统bat批处理 mysql 脚本启动关闭
54 3
|
29天前
|
Windows
windows系统vbs脚本 恶搞关不掉的窗口 以及解决办法
windows系统vbs脚本 恶搞关不掉的窗口 以及解决办法
21 2
|
29天前
|
Windows
windows系统vbs脚本 恶搞将系统搞崩 死机 以及解决
windows系统vbs脚本 恶搞将系统搞崩 死机 以及解决
16 1
|
29天前
|
Windows
windows系统vbs脚本 提取文件夹中的所有文件名
windows系统vbs脚本 提取文件夹中的所有文件名
19 0
|
1月前
|
应用服务中间件 nginx Windows
windows系统bat批处理 管理nginx启动 nginx脚本管理bat脚本管理生命周期windows一键nginx启动
windows系统bat批处理 管理nginx启动 nginx脚本管理bat脚本管理生命周期windows一键nginx启动
18 0
|
1月前
|
Java Windows
windows bat脚本实现快速配置JDK 环境变量
windows bat脚本实现快速配置JDK 环境变量
16 0
|
1月前
|
Linux 网络安全 Windows
ssh连接缓慢 ssh连接失败问题 Linux 脚本解决ssh连接缓慢问题,windows解决本地ssh连接失败
ssh连接缓慢 ssh连接失败问题 Linux 脚本解决ssh连接缓慢问题,windows解决本地ssh连接失败
33 0
|
2月前
|
Windows
【Windows】 手写脚本更快编辑hosts文件
【Windows】 手写脚本更快编辑hosts文件
37 0
|
2月前
|
存储 数据可视化 数据库
InfluxData【付诸实践 01】Windows环境部署Telegraf+Influxdb+Grafana安装及使用配置(含百度云盘资源+demo脚本)
InfluxData【付诸实践 01】Windows环境部署Telegraf+Influxdb+Grafana安装及使用配置(含百度云盘资源+demo脚本)
131 0