使用 CDO JavaScript 发送邮件错误 - 服务器未定义
我得到了使用 SMTP 服务器发送电子邮件的代码,我尝试了在网上找到的许多配置,还有 VBscript 类似的代码,但没有一个有效。
我想重点关注这段代码,当我打开 HTA 时,我在第 8 行收到错误,显示“服务器未定义”,我应该如何定义它?
var cdoConfig = Server.CreateObject("CDO.Configuration");
cdoConfig.Fields("cdoSMTPServerName") = "194.90.9.22";
var cdoMessage = Server.CreateObject("CDO.Message");
cdoMessage.Configuration = cdoConfig;
var cdoBodyPart = cdoMessage.BodyPart;
cdoMessage.To = "[email protected]";
cdoMessage.From = "[email protected]";
cdoMessage.Subject = "CDO Test in JScript";
cdoMessage.TextBody = "This is a test email sent using JScript.";
cdoMessage.send();
谢谢, 罗特姆
I got this code to send email using SMTP server, I tried many configuration of it that I found online, also VBscript similar code, and non of it is working.
I want to focus on this code, when I'm opening the HTA I'm getting error in line 8, says 'Server is undefined', What should I do to define it?
var cdoConfig = Server.CreateObject("CDO.Configuration");
cdoConfig.Fields("cdoSMTPServerName") = "194.90.9.22";
var cdoMessage = Server.CreateObject("CDO.Message");
cdoMessage.Configuration = cdoConfig;
var cdoBodyPart = cdoMessage.BodyPart;
cdoMessage.To = "[email protected]";
cdoMessage.From = "[email protected]";
cdoMessage.Subject = "CDO Test in JScript";
cdoMessage.TextBody = "This is a test email sent using JScript.";
cdoMessage.send();
Thanks,
Rotem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Jan,您应该看到代码使用“服务器”(VBS),是否推荐?
您可以检查一下:
希望这有帮助,
Jan, you should see that code uses "Server" (VBS), is it recommended ¿?
You may check this:
Hope this helps,
抱歉,延迟响应看起来不像使用服务器 IP,您需要指定服务器地址,例如 smptout.secureserver.net,但替换为您的 smpt 地址,而且大多数 smtp 服务器需要用户名和密码,您需要在代码中定义这些。
在vbs中,它的定义如下,所以
我不太了解js,所以我无法将vbs代码转换为在js中工作。我希望这是一些帮助
sorry for the delayed response looks like instead of using the server ip you need to spicify the server address for example smptout.secureserver.net but replace with your smpt address also most smtp server require username and password you will need to define these in your code.
in vbs it would be defined like so
i do not know js very well so i am unable to convert the vbs code to work in js. i hope this is some help