使用 CDO JavaScript 发送邮件错误 - 服务器未定义

发布于 2024-10-09 03:15:39 字数 859 浏览 1 评论 0原文

我得到了使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

格子衫的從容 2024-10-16 03:15:39

Jan,您应该看到代码使用“服务器”(VBS),是否推荐?

您可以检查一下:

  1. 您的服务器(运行代码)不允许发送(邮件转发)。
  2. Auth, .Item(cdoSMTPAuthenticate) = cdoAnonymous,您应该查看您的邮件服务器上是否有一些身份验证。

希望这有帮助,

Jan, you should see that code uses "Server" (VBS), is it recommended ¿?

You may check this:

  1. Your server(running the code) is not allowed to send (mail forwarding).
  2. Auth, .Item(cdoSMTPAuthenticate) = cdoAnonymous, you should see if there's some auth on your mail server.

Hope this helps,

冬天的雪花 2024-10-16 03:15:39

抱歉,延迟响应看起来不像使用服务器 IP,您需要指定服务器地址,例如 smptout.secureserver.net,但替换为您的 smpt 地址,而且大多数 smtp 服务器需要用户名和密码,您需要在代码中定义这些。
在vbs中,它的定义如下,所以

Set emailConfig = emailObj.Configuration
emailConfig.Fields("smtpserver") = "your smtp address"
emailConfig.Fields("smtpserverport") = your smpt port
emailConfig.Fields("sendusing")= 2  
emailConfig.Fields("smtpauthenticate") = 1  
emailConfig.Fields("smtpusessl") = true/false "used for ssl" 
emailConfig.Fields("sendusername") = "your smtp username"
emailConfig.Fields("sendpassword") = "your smtp password"
emailConfig.Fields.Update

我不太了解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

Set emailConfig = emailObj.Configuration
emailConfig.Fields("smtpserver") = "your smtp address"
emailConfig.Fields("smtpserverport") = your smpt port
emailConfig.Fields("sendusing")= 2  
emailConfig.Fields("smtpauthenticate") = 1  
emailConfig.Fields("smtpusessl") = true/false "used for ssl" 
emailConfig.Fields("sendusername") = "your smtp username"
emailConfig.Fields("sendpassword") = "your smtp password"
emailConfig.Fields.Update

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文