Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Script Error

Status
Not open for further replies.

rene316

Programmer
Jan 14, 2002
81
US
Hello,

I am trying to write a VB Script to send out a text email, however when I execute the script I get this error...
-----------------------------------------------------------
Error: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Code: 800A0BB9

Source: ADODB.Fields
----------------------------------------------------------

Here is the code:

Dim iMsg
Dim iConf
Dim Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = iMsg.Configuration
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "localhost" 'set as appropriate
Flds(cdoSMTPServerPort) = 25 'set as appropriate
Flds.Update
Set Flds = Nothing
With iMsg
.To = "me@mycompany.com"
.From = "me@mycompany.com"
.CC = "me@mycompany.com"
.Subject = "Your lights are on, but no one is home"
.TextBody = "You left your lights on this morning."
.Fields.Update
.Send
End With
Set iMsg = Nothing


Anyone see where my problem is? Any help is much appreciated.

Thanks in advance.
Rene
 
This error usually means that there is a problem with the connection string or the odbc driver is bad. Check to make sure the connection string is correct.

Dodge20
 
You have to define the cdoXXX constants.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Here is a script I use to let me know when a server reboots.
Has all of the code you need for sending an email.

Code:
'==========================================================================
'
' VBScript Source File -- 
'
' NAME: NotifyReboot.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]	
' DATE  : 02/13/2003
'
' COMMENT: 
'
' This script can be added to a machines startup script in Group Policy to notify
' an e-mail address that the machine has restarted.
'
' You must customize the entries for oDomain, oMyIP and oTo with the proper company information.
' Items to customize are on lines 29, 31 and 33.
'=====================================
 
Dim oName, ODomain, oMyIP, oTo

' Get the computer name
Set WshNetwork = CreateObject("WScript.Network")
oName = WshNetwork.ComputerName

' Set the company specific information

' Company Internet Domain Name
ODomain = "thespidersparlor.com"
' Set the SMTP server IP
oMyIP = "192.168.1.1" 
' Where do you want the message to be delivered
oTo = "markdmac@thespidersparlor.com"


' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.
Const cdoSendUsingMethod = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _
cdoSendUsingPort = 2, _
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL]

'// Create the CDO connections.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

'// SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort

'// Set the SMTP server address here.
.Item(cdoSMTPServer) = oMyIP
.Update
End With

'// Set the message properties.
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oName & "@" & oDomain
.Subject = "Server Reboot"
.TextBody = "Server " & oName & " at company " & ODomain & " was restarted " & now
End With

'// An attachment can be included.
'iMsg.AddAttachment Attachment

'Send the message.
iMsg.Send 

MsgBox "Done"

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Thank you all for your help. After some sleepless nights and many different scripts, I ended up getting it to work. All your comments help point me in the right direction. It was a combination of the code and the server(evil Microsoft, lol). Once again, thank you all, your input was most valuable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top