Pegasus
Tue Mar 25 02:51:47 CDT 2008
"£¤£¤£¤" <eagle@no.spam.net> wrote in message
news:usDQAlkjIHA.484@TK2MSFTNGP06.phx.gbl...
> It works well to send email to intranet email-box.
> If I try to send email to a extranet email-box,the script will issue the
> following information when it executes the last line " objEmail.send "
>
> ------ information---------
> (null): The server rejected one or more recipient addresses. The server
> response was: 554 Relay rejected for policy reasons.
>
>
> ####################VBS code#############
> Set objEmail = CreateObject("CDO.Message")
> objEmail.From = "name@xxx.com.cn"
> objEmail.To = "extranet@xxx.com.cn"
>
> objEmail.Subject = "Server down"
> objEmail.Textbody = "No longer accessible over the network."
> objEmail.Configuration.Fields.Item _
> ("
http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
> objEmail.Configuration.Fields.Item _
> ("
http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
> "192.168.0.1" 'this is mail server IP.
> objEmail.Configuration.Fields.Item _
> ("
http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
> objEmail.Configuration.Fields.Update
> objEmail.Send
>
You've got most of the required stuff in your code but you need
to replace the SMTP server's IP address with name of your ISP's
SMTP server. Here is a modified version of your code. I have
tightened it up a little to make it more readable.
schema = "
http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "name@xxx.com.cn"
.To = "extranet@xxx.com.cn"
.Subject = "Server down"
.Textbody = "No longer accessible over the network."
' .AddAttachment "d:\Testfile.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.SomeISP.com"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = "name@xxx.com.cn"
.Item (schema & "sendpassword") = "SomePassword"
End With
.Configuration.Fields.Update
.Send
End With