在LINUX下, 你可以通过安装 sendmail 程序并通过 mail 命令方便的发邮件. 在WINDOWS下, 你可以通过以下VBSCRIPT在WINDOWS的宿主脚本环境(Windows Scripting Host)下运行.
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 | ' VBScript to Send Email Notification ' Author: https://helloacm.com ' Usage: cscript.exe sendemail.vbs email subject text ' 23/Dec/2014 Sub SendEmail(ToAddress, Subject, Text) Dim iMsg Dim iConf Dim Flds Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "gmail account" .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "gmail password" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'smtp mail server .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'stmp server .Update End With With iMsg Set .Configuration = iConf .To = ToAddress .From = "dr.zhihua.lai at gmail.com" .Subject = Subject .TextBody = Text .Send End With Set iMsg = Nothing Set iConf = Nothing End Sub If WScript.Arguments.Count <> 3 Then WScript.Echo "Usage: cscript.exe " & WScript.ScriptFullName & " email subject text" Else SendEmail WScript.Arguments(0), WScript.Arguments(1), WScript.Arguments(2) End If |
' VBScript to Send Email Notification ' Author: https://helloacm.com ' Usage: cscript.exe sendemail.vbs email subject text ' 23/Dec/2014 Sub SendEmail(ToAddress, Subject, Text) Dim iMsg Dim iConf Dim Flds Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "gmail account" .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "gmail password" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'smtp mail server .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'stmp server .Update End With With iMsg Set .Configuration = iConf .To = ToAddress .From = "dr.zhihua.lai at gmail.com" .Subject = Subject .TextBody = Text .Send End With Set iMsg = Nothing Set iConf = Nothing End Sub If WScript.Arguments.Count <> 3 Then WScript.Echo "Usage: cscript.exe " & WScript.ScriptFullName & " email subject text" Else SendEmail WScript.Arguments(0), WScript.Arguments(1), WScript.Arguments(2) End If
在使用这个脚本前, 你必须把用户名和密码都改成你自己的帐号,然后在命令行下可以通过 cscript.exe 来解释运行这脚本.
C:\Windows\system32>cscript.exe sendemail.vbs [email protected] "Hello World" "http://helloacm.com" Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. C:\Windows\system32>
这样, 比如系统每天运到些什么不太正常的情况(比如SVN上有人提交代码编译不过或者没通过单元测试),那么就发邮件提醒你,以免拖太久难于修复.
英文同步: https://helloacm.com/how-to-send-email-using-vbscript-and-gmail-ssl/
GD Star Rating
loading...
本文一共 152 个汉字, 你数一下对不对.loading...
上一篇: 年底了, 你涨工资了么?
下一篇: 简洁的英文: She told him that she loved him
扫描二维码,分享本文到微信朋友圈

巧了,我最近也在整vbscript,不过是科研上要用来建模.
LINUX下, 你可以通过安装 sendmail 程序并通过 mail 命令方便的发邮件. 在WINDOWS下, 你可以通过以下VBSCRIPT在WINDOWS
你这全角和半角是怎么规定的?看起来怪怪的.还是统一一下吧,包括你的标点,也是很混乱,这可影响阅读性啊.
嗯, 全部两个SQL替换了.
UPDATE wp_posts SET post_content = REPLACE (post_content, ‘,’, ‘,’);# 233 rows affected.
UPDATE wp_posts SET post_content = REPLACE (post_content, ‘.’, ‘.’);# 233 rows affected.
你这一下更绝了,将本应中文的标点全部换成英文标点了,看起来很怪怪的感觉.
哈哈..没事的. 统一就可以.
因为普通英文的逗号和句号有可能是其它用途, 所以不能全部替换
说的就是这个,我还疑惑你用批量替换的方法怎么解决代码的点号呢,原来你是全是换成了英文标点符号了.
技术性真强啊