Email 当我尝试运行这个VB脚本时,它显示“需要对象”,我找不到错误

Email 当我尝试运行这个VB脚本时,它显示“需要对象”,我找不到错误,email,vbscript,Email,Vbscript,我用Notepad++编写了这段代码,并将其保存为.vbs文件,然后尝试运行它,但遇到了“对象要求”错误。我找不到问题 Dim objMessage Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "ALARMNO SPOROĆILO Z NADZORNEGA SISTEMA" objMessage.From = "someemail@hotmail.com" objMessage.To = "toemail@

我用Notepad++编写了这段代码,并将其保存为.vbs文件,然后尝试运行它,但遇到了“对象要求”错误。我找不到问题

Dim objMessage
Set objMessage = CreateObject("CDO.Message")

objMessage.Subject = "ALARMNO SPOROĆILO Z NADZORNEGA SISTEMA"
objMessage.From = "someemail@hotmail.com"
objMessage.To = "toemail@hotmail.com"
objMessage.HTMLBody = "Zdravo"

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "someemail@gmail"

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "00000000000000"


objMessage.Configuration.Fields.Update

REM Now send the message

On error Resume Next
Obj.Message.Send

IF err.Number <> 0 Then

MsgBox Err.Description,16,"Error sending Mail "
Else
MsgBox " Message sent "
END IF 

通过更多的搜索,我在互联网上找到了这个……如果其他人需要解决方案,它就是……如果有人能在我自己的脚本中解释我哪里出错了……我将不胜感激。

我怀疑你的原始脚本失败是因为你


'Create the objects require for sending email using CDO
Set objMail = CreateObject("CDO.Message")
Set objConf = CreateObject("CDO.Configuration")
Set objFlds = objConf.Fields

'Set various parameters and properties of CDO object
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
'your smtp server domain or IP address goes here such as smtp.yourdomain.com
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'uncomment next three lines if you need to use SMTP Authorization
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "email@gmail.com"
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
objFlds.Update
objMail.Configuration = objConf
objMail.From = "email@gmail.com"
objMail.To = "email@hotmail.com"
objMail.Subject = "Put your email's subject line here"
objMail.TextBody = "Your email body content goes here"
objMail.Send

'Set all objects to nothing after sending the email
Set objFlds = Nothing
Set objConf = Nothing
Set objMail = Nothing

。。。而不是

Obj.Message.Send

你必须打开GMail选项中的不安全应用设置。你好,马克……谢谢你的回答。我已经这么做了…但还是不起作用,如果你有任何其他建议,我将不胜感激。GMail给你发了一封电子邮件,你必须点击其中的链接吗?请参见我关于询问Windows原因的回答。是的,gmail工作得很好…我用我在下面发布的脚本确认了它…它工作得很好。它只是不想与上面写的脚本和idk为什么工作。我很感谢你的帮助。设置objConf=CreateObjectCDO.Configuration你没有这一行。是的,我自己也弄明白了……无论如何,谢谢你抽出时间来……该死的,这个网站上的大多数人都很严格……并且否决了一切xD……谢谢。。。。
objMessage.Send