Solved

VBScript WScript error

Posted on 2011-09-29
2
797 Views
Last Modified: 2012-06-22
I originally had this code as a Sub within another VBScript and it functioned correctly.

But now I need it as a standalone script at get this runtime error:
Object doesn't support this property or method: WScript.Arguments

So I have left something out to be able to correctly receive the command line arguments.  Can anyone please point out my error(s)?
''Sub SendIt(ByVal msgType, ByVal strSubject, ByVal strMessage)

Dim myShell
Dim myProcEnv
Set myShell = CreateObject("WScript.Shell")
 
Dim msgType     :               WScript.Arguments(0)
Dim strSubject  :               WScript.Arguments(1)
Dim strMessage  :               WScript.Arguments(2)
    Dim jm  : jm=False
               
               
    If (ucase(GetXMLText("Email\Enabled"))="TRUE") and GetXMLText("Email\SMTP")<> "" Then
        SetXMLText "Email\Enabled" , "True"
        jm=True
    Else
        SetXMLText "Email\Enabled" , "False"
        jm=False
        'Exit Sub
                                Response.End
    End If
 
    Dim Recipients : Recipients=0
        on error resume next
 
    Dim xmlDoc      ' Main XML document
    Set xmlDoc = GLOBAL_GetXMLDoc
 
    Dim mainNode    ' Main XML document
 
    Recipients = xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("Recipient").Length
 
    If Recipients = 0 Then
        On Error Goto 0
        'Exit Sub
         Response.End
    End If
 
Dim fullMessage : fullMessage = ""
    fullMessage = fullMessage & GetXMLText("Email\EmailPrefix") & vbCrlf & vbCrlf
 
    Dim sType
    Select Case ucase(msgType)
        Case "SUCCESS"      : fullMessage = fullMessage & GetXMLText("Email\EmailSuccessMessage")  : sType = "Success"
        Case "FAILURE"      : fullMessage = fullMessage & GetXMLText("Email\EmailFailureMessage")  : sType = "Failure"
        Case "STATUS"       : fullMessage = fullMessage & GetXMLText("Email\EmailStatusMessage")   : sType = "Status"
        Case Else           : fullMessage = fullMessage & "<Invalid Message Type>"
    End Select
 
    fullMessage = fullMessage & vbCrlf & vbCrlf & strMessage & vbCrlf & vbCrlf
 
    fullMessage = fullMessage & GetXMLText("Defaults\EmailSuffix") & vbCrlf & vbCrlf
 
    Dim jmail
 
    If jm Then
         Set jmail = CreateObject("JMail.Message")
         jmail.silent=true
         jmail.logging=true
 
         jmail.from         = xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("From").item(rCtr).getattribute("Address")
         jmail.fromname     = xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("From").item(rCtr).getattribute("name")
    End If
 
' for each email address in MAIN DEFAULTS
' for each email address in EMAIL.RECIPIENT
    Dim rCtr : rCtr=0
    Do While rCtr < Recipients
        If xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("Recipient").item(rCtr).getattribute(sType)="True" Then
            If jm Then     jmail.AddRecipient xmlDoc.getElementsByTagName("Email").item(0).getElementsByTagName("Recipient").item(rCtr).getattribute("Address")
        End If
        rCtr = rCtr + 1
    Loop
 
    If jm Then
        jmail.subject      = strSubject
        jmail.body         = fullMessage
        If objFSO.FileExists(replog) then
            jmail.AddAttachment  replog
        End If
        jmail.send( GetXMLText("Email\SMTP") )
    End If
 
' Clean up...
    Set jmail=Nothing
'''End Sub

Open in new window

0
Comment
Question by:kkbenj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
jawa29 earned 500 total points
ID: 36815009
Hi

All you need to do is chnage it to this
Dim msgType : msgType = WScript.Arguments(0)
Dim strSubject : strSubject = WScript.Arguments(1)
Dim strMessage : strMessage = WScript.Arguments(2)

Jawa29
0
 

Author Closing Comment

by:kkbenj
ID: 36815104
an oversight for sure.

Thanks for the clarity.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question