在VBS中实现xp_sendmail

时间:2016-07-26 01:58:43

标签: sql-server vbscript

ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=mydb;Data Source=myserver" 
Set dbconn = CreateObject("ADODB.Connection")
dbconn.Open ConnectionString

DIM cmd
SET cmd = server.CreateObject("ADODB.Command")
SET cmd.ActiveConnection = Connection

cmd.CommandText = "xp_sendmail"
cmd.CommandType = 4 

cmd.Parameters("@Recipients") = "me@me.com" 
cmd.Parameters("@Subject") = "Test" 
cmd.Parameters("@message") = "Test" 

cmd.Execute

我的脚本给了我一个错误:

  

需要对象:'server'

任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

查看here以了解为什么以及如何使用。附加参数。