
Utilizo este script para enviar correos electrónicos a personas. Envío mensajes cortos todo el tiempo, además de actualizar mirecuerda la lechetodo es de launchy.
Cuando necesito agregar una nueva tarea simplemente
- Golpearespacio+alt(invocalanzador)
- tipoRR
- golpearpestaña
- escribe "esta es mi tarea"
- presione enter
Lo que me gustaría hacer es no tener que escribir el "" ya que me ralentiza mucho.
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") = "[email protected]"
Flds.Item(schema & "sendpassword") = "YOURPASSWORD"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "[email protected]"
.From = "jacob <[email protected]"
.Subject = wscript.arguments.item(0)
.HTMLBody = message
.Sender = " "
.Organization = " "
.ReplyTo = " "
Set .Configuration = iConf
SendGMAILGmail = .Send
End With
set iMsg = nothing
set iConf = nothing
set Flds = nothing
Respuesta1
No estoy seguro de entender completamente la pregunta, pero supongo que su tarea se ejecuta pasando lo que escriba como argumentos de la línea de comando al script y, como lo está utilizando wscript.arguments.item(0)
como asunto, debe agregar comillas. asegúrese de que el tema completo esté incluido en el primer argumento.
Usando el código (un poco loco) deaquí, lo siguiente debería funcionar
Set oWMISrvc = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\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") = "[email protected]"
Flds.Item(schema & "sendpassword") = "YOURPASSWORD"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "[email protected]"
.From = "jacob <[email protected]"
.Subject = sArguments
.HTMLBody = message
.Sender = " "
.Organization = " "
.ReplyTo = " "
Set .Configuration = iConf
SendGMAILGmail = .Send
End With
set iMsg = nothing
set iConf = nothing
set Flds = nothing
Alternativamente, simplemente concatene todos los argumentos proporcionados:
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") = "[email protected]"
Flds.Item(schema & "sendpassword") = "YOURPASSWORD"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "[email protected]"
.From = "jacob <[email protected]"
.Subject = sArguments
.HTMLBody = message
.Sender = " "
.Organization = " "
.ReplyTo = " "
Set .Configuration = iConf
SendGMAILGmail = .Send
End With
set iMsg = nothing
set iConf = nothing
set Flds = nothing
El método a utilizar dependerá de sus requisitos. El primer método conservará todas las comillas en la línea de comando, mientras que el segundo método ignorará el espacio entre palabras.