Solved

VBScript WScript error

Posted on 2011-09-29
2
761 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
2 Comments
 
LVL 8

Accepted Solution

by:
jawa29 earned 500 total points
Comment Utility
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
Comment Utility
an oversight for sure.

Thanks for the clarity.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now