关于VBS的运行环境

iamli2000 2015-01-22 02:58:06
请问我有一个vbs脚本,在windows 2003 r2(32bit)系统下可以运行,在win 7(32bit)和win2008 r2(64bit)下报错
行:0
字符:1
错误:邮件无法发送到SMTP服务器。传输错误代码为0x800ccc67,。服务器响应为421 4.3.2 service not avaiable。

以下是脚本内容
dim fs3,emailto,emailcc
emailto="收件人地址"

set fs3=wscript.createobject("scripting.filesystemobject")



call SendEmail("发件人邮箱","发件人密码",emailto,emailcc,"警报","有一条错误","")
'Wscript.Echo "发送成功"






'Option Explicit
'**************************************** 参数设置 ****************************************

Const SENDER_MAIL_ADDR = "xxxxxx@qq.com"'用于发送邮件的邮箱地址
Const SENDER_MAIL_PWD = "xxxxxx" '用于发送邮件的邮箱密码
Const SENDEE_MAIL_ADDR = "xxxxxx@qq.com" '用于接收邮件的邮箱地址
Const Backup_MAIL_ADDR = "xxxxxx@qq.com" '接收邮件的备用邮箱地址
Const Send_MailTitle = "xxxxxx" '邮件主题
Const Send_MailContent = "xxxxxx" '邮件内容
Const Send_MailAttachment = "" '附件地址,可省略

'******************************************************************************************

'发送邮件
'Call SendEmail(SENDER_MAIL_ADDR, SENDER_MAIL_PWD, SENDEE_MAIL_ADDR, SENDEE_MAIL_ADDR, Send_MailTitle, Send_MailContent, Send_MailAttachment)

'********************************** 声明SendEmail过程 *************************************

Function SendEmail(SenderAddress, SenderPassword, SendeeAddress, BackupAddress, MailTitle, MailContent, MailAttachment)
Const MS_Space = "http://schemas.microsoft.com/cdo/configuration/" '配置空间

Dim objEmail,f2
Set objEmail = CreateObject("CDO.Message")
set f2=wscript.createobject("scripting.filesystemobject")


Dim strSenderID
strSenderID = Split(SenderAddress,"@",-1,vbTextCompare)

objEmail.From = SenderAddress '寄件人地址
objEmail.To = SendeeAddress '收件人地址
If BackupAddress <> "" Then
objEmail.CC = BackupAddress '备用地址
End If
objEmail.Subject = MailTitle '邮件主题
objEmail.TextBody = MailContent '邮件内容

If f2.fileexists(fname1) then
objEmail.AddAttachment MailAttachment '附件地址
End If

With objEmail.Configuration.Fields
.Item(MS_Space & "sendusing") = 2 '发信端口
.Item(MS_Space & "smtpserver") = "10.2.2.24" '发信服务器
.Item(MS_Space & "smtpserverport") = 250 'SMTP服务器端口
.Item(MS_Space & "smtpauthenticate") = 1 'CDObasec
.Item(MS_Space & "sendusername") = strSenderID(0) '寄件人邮箱账户名
.Item(MS_Space & "sendpassword") = SenderPassword '帐户名密码
.Update
End With
Dim str
str="objEmail.Send" '发送邮件
Execute str
Set objEmail = Nothing
'SendEmail = True

If Err Then
Err.Clear
SendEmail = False
End If
End Function

...全文
1453 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dogfish 2015-03-10
  • 打赏
  • 举报
回复
把文件的编码转成ANSI格式就没问题的了。
wudaomoze 2015-02-26
  • 打赏
  • 举报
回复
端口改成25试试

4,009

社区成员

发帖
与我相关
我的任务
社区描述
它是一种微软环境下的轻量级的解释型语言,它使用COM组件、WMI、WSH、ADSI访问系统中的元素,对系统进行管理。
社区管理员
  • vbScript社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧