我正在尝试了解Classic ASP或命令行VBScript应用程序无法发送电子邮件的方式。以下脚本基于各种来源。当我尝试从Windows 7 VM上的命令/行运行它时,我收到错误
CDO.Message.1:“SendUsing”配置值无效。
事情是,我根据旨在解决该错误的示例编写了脚本!有什么建议吗?
Dim fso, stderr, inX, mail, buf, schemaNode
Set fso = CreateObject("Scripting.FileSystemObject")
Set StdErr = fso.GetStandardStream(2)
Set mail = CreateObject("CDO.Message")
schemaNode = "http://schemas.microsoft.com/cdo/configuration/"
With mail.Configuration.Fields
.Item(schemaNode & "sendusing") = 2 'Send the message using the network (SMTP)
.Item(schemaNode & "smtpserver") = "my/mail/server"
.Item(schemaNode & "smtpserverport") = 25
.Item(schemaNode & "smtpserverpickupdirectory") = "C:\TEMP"
End With
buf = ""
mail.From = "noreply@my/domain"
mail.To = "some/user@my/domain"
mail.Subject = "Test - via VBScript - " & fso.getTempName()
Set inX = fso.OpenTextFile("template.txt", 1)
Do While inX.AtEndOfStream = False
buf = buf & inX.ReadLine
Loop
mail.TextBody = buf
mail.Send()
StdErr.WriteLine("OK.")
答案 0 :(得分:1)
您永远不会将更改应用于邮件配置。此外,使用拾取目录仅与通过拾取向本地邮件服务器提交邮件相关(即通过将邮件(文件)放在邮件服务器拾取的目录中),而不是通过SMTP提交邮件时。
改变这个:
With mail.Configuration.Fields
.Item(schemaNode & "sendusing") = 2
.Item(schemaNode & "smtpserver") = "my/mail/server"
.Item(schemaNode & "smtpserverport") = 25
.Item(schemaNode & "smtpserverpickupdirectory") = "C:\TEMP"
End With
进入这个:
With mail.Configuration.Fields
.Item(schemaNode & "sendusing") = 2
.Item(schemaNode & "smtpserver") = "my/mail/server"
.Item(schemaNode & "smtpserverport") = 25
.Update
End With
问题就会消失。