Solved

VBScript WScript error

Posted on 2011-09-29
2
782 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 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