Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBScript WScript error

Posted on 2011-09-29
2
Medium Priority
?
836 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

610 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