
Ich verwende dieses Skript, um E-Mails an Personen zu senden, denen ich ständig Kurznachrichten schicke, sowie um meineerinner dich an die MilchAufgaben von Launchy.
Wenn ich eine neue Aufgabe hinzufügen muss,
- SchlagAlt+Leertaste(ruft aufstartklar)
- Typrr
- SchlagTab
- Geben Sie „das ist meine Aufgabe“ ein.
- Drücken Sie Enter
Ich möchte das "" nicht schreiben müssen, da es mich sehr verlangsamt.
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
Antwort1
Ich bin nicht sicher, ob ich die Frage ganz verstehe, aber ich nehme an, dass Ihre Aufgabe ausgeführt wird, indem Sie alles, was Sie eingeben, als Befehlszeilenargumente an das Skript übergeben, und da Sie wscript.arguments.item(0)
als Betreff verwenden, müssen Sie Anführungszeichen hinzufügen, um sicherzustellen, dass der vollständige Betreff im ersten Argument enthalten ist.
Mit dem (etwas verrückten) Code vonHiersollte das Folgende funktionieren
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
Alternativ können Sie einfach alle angegebenen Argumente verketten:
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
Die zu verwendende Methode hängt von Ihren Anforderungen ab. Bei der ersten Methode bleiben alle Anführungszeichen in der Befehlszeile erhalten, während bei der zweiten Methode die Leerzeichen zwischen Wörtern ignoriert werden.