I'm not sure I fully understand the question, but I'm assuming that your task is run by passing in whatever you type as the command line arguments to the script, and because you are using wscript.arguments.item(0)
as the subject you need to add quotes to ensure that the full subject is included in the first argument.
Using the (slightly crazy) code from here, the following should work
Set oWMISrvc = GetObject("winmgmts:" _ & "!\\.\root\cimv2") sProcName = Mid(wsh.fullname, InstrRev(wsh.fullname, "\") + 1) Set cProcesses = oWMISrvc.ExecQuery( _ "select * from win32_process where Name = '" & sProcName & "'") For Each oProcess in cProcesses If Instr(lcase(oProcess.Commandline), lcase(wsh.scriptname)) > 0 Then sCmdLine = oProcess.Commandline End If Next iNamePos = instr(lcase(sCmdLine), lcase(Wscript.ScriptName)) sArguments = trim(mid(sCmdLine, iNamePos + len(Wscript.ScriptName))) Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields schema = "http://schemas.microsoft.com/cdo/configuration/" Flds.Item(schema & "sendusing") = 2 Flds.Item(schema & "smtpserver") = "smtp.GMAIL.com" Flds.Item(schema & "smtpserverport") = 465 Flds.Item(schema & "smtpauthenticate") = 1 Flds.Item(schema & "sendusername") = "YOU@GMAIL.COM" Flds.Item(schema & "sendpassword") = "YOURPASSWORD" Flds.Item(schema & "smtpusessl") = 1 Flds.Update With iMsg .To = "RECIEVER@MAIL.COM" .From = "jacob <YOU@GMAIL.COM" .Subject = sArguments .HTMLBody = message .Sender = " " .Organization = " " .ReplyTo = " " Set .Configuration = iConf SendGMAILGmail = .Send End With set iMsg = nothing set iConf = nothing set Flds = nothing
Alternatively just concatenate all provided arguments:
sArguments = "" For i = 0 to Wscript.Arguments.Count - 1 if i > 0 Then sArguments = sArguments + " " End If sArguments = sArguments + Wscript.Arguments(i) Next Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields schema = "http://schemas.microsoft.com/cdo/configuration/" Flds.Item(schema & "sendusing") = 2 Flds.Item(schema & "smtpserver") = "smtp.GMAIL.com" Flds.Item(schema & "smtpserverport") = 465 Flds.Item(schema & "smtpauthenticate") = 1 Flds.Item(schema & "sendusername") = "YOU@GMAIL.COM" Flds.Item(schema & "sendpassword") = "YOURPASSWORD" Flds.Item(schema & "smtpusessl") = 1 Flds.Update With iMsg .To = "RECIEVER@MAIL.COM" .From = "jacob <YOU@GMAIL.COM" .Subject = sArguments .HTMLBody = message .Sender = " " .Organization = " " .ReplyTo = " " Set .Configuration = iConf SendGMAILGmail = .Send End With set iMsg = nothing set iConf = nothing set Flds = nothing
the method to use will depend on your requirements. The first method will retain all quotes on the command line while the second method will ignore the spacing between words.