Ich brauche Hilfe mit meinem ersten VBS-Skript. Grundsätzlich möchte ich prüfen, ob Outlook geöffnet ist, wenn ich das Programm nicht öffnen möchte, wenn/wann es geöffnet ist möchte ich eine E-Mail senden.Outlook senden E-Mail senden
set service = GetObject ("winmgmts:")
for each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = "outlook.exe"(
goto "send"
) else (
goto "Open"
)
End If
Open:
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("""C:\Program Files (x86)\Microsoft Office\Office16\OUTLOOK.EXE""")
Set objShell = Nothing
GOTO send
send:
wscript.Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Sign in- please reply!"
objMessage.Sender = "[email protected]"
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = Test Body Email
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
exit
Ich weiß, dass mein E-Mail-Teil funktioniert, wie ich das ausführen und meine E-Mail senden kann. Ich habe Probleme mit der Aussage "Wenn, SONST, DANN".