【发布时间】:2014-01-23 19:17:03
【问题描述】:
我使用下面的 VB 脚本来发送电子邮件。当我从命令提示符执行它时,它会在执行后返回到命令提示符。如果发送时出现任何错误,则会显示一条弹出消息。
If WScript.Arguments.Count <> 6 then
Wscript.Echo "Missing parameters"
Else
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = Wscript.Arguments(0)
objMessage.From = Wscript.Arguments(1)
objMessage.To = Wscript.Arguments(2)
objMessage.TextBody = Wscript.Arguments(3)
objMessage.AddAttachment Wscript.Arguments(4)
objMessage.AddAttachment Wscript.Arguments(5)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp server ip"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
End If
我想知道在程序中发送邮件和获取objMessage.Send的状态需要多少时间。
我想使用 Wscript.Echo “错误消息”来显示错误。上面的代码需要做哪些修改,以便执行等到邮件发送成功,然后显示消息。
提前致谢。 阿肖克
【问题讨论】: