Error: The “SendUsing” configuration value is invalid

That was the error I was receiving when trying to send an e-mail using CDONTS in a VBS script. But I found a post by Jeff on forums.iis.net that was exactly what I was looking for.

The script was created to be run daily as a scheduled task, and to notify a user when disk space dropped below 15% of the drive’s total storage capacity.

This is the complete script, with comments at the end:
Option Explicit

Dim objFSO
Dim objDrive
Dim TotalSize
Dim AvailableSpace
Dim Percent
Dim objEmail

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDrive = objFSO.GetDrive("C:")
AvailableSpace = objDrive.AvailableSpace
TotalSize = objDrive.TotalSize
Percent = (AvailableSpace / TotalSize) * 100
If Percent > 15 Then
 Set objEmail = CreateObject("CDO.Message")
 objEmail.From = "myemail@scottsserver.com"
 objEmail.To = "myemail@scottsserver.com"
 objEmail.Subject = "Server ZZZ is running low on disk space"
 objEmail.Textbody = "Server ZZZ is running low on disk space. " & AvailableSpace / 1024 & "MB is remaining of the total disk size of " & TotalSize / 1024 & "MB."
 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver.scottsserver.com"
 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
 objEmail.Configuration.Fields.Update
 objEmail.Send
End If
WScript.Quit

The script originally was created without these lines:

 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver.scottsserver.com"
 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
 objEmail.Configuration.Fields.Update

The error was thrown at the objEmail.Send line. After adding the lines, it worked perfectly.

Advertisements
  1. #1 by Deep Satyawali on May 10, 2013 - 5:45 am

    I have checked this problem with few machines and observed we need to have IIS server on the machine to get rid of this error…

    Install IIS Server in the machine where you are running this code this may work

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: