I really don't know much about VB script, and I could use some help with this little problem.
I'm trying send an email once a certain script is run every morning (a scheduled task). Now, our email server is configured to prevent sending automated emails - a feature I generally appreciate - and so I need to simulate a keystroke to acknowledge a warning box and actually send the email.
Here's the script I have so far:
Sub SendEmail_Outlook()
Set WshShell = WScript.CreateObject("WScript.Shell")
Set ol=CreateObject("Outlook.Application")
Set Mail=ol.CreateItem(0)
Mail.to= "X@xyz.com"
Mail.Subject = "Subject"
Mail.HTMLBody = "Body"
Mail.Display
WScript.Sleep 1000
WshShell.SendKeys "%s"
Set Mail = Nothing
Set ol = Nothing
End Sub
SendEmail_Outlook
The script works like a charm, but only if I'm logged in. If I'm not logged in, the email draft is prepared, the window is activated, but the email is not actually sent. I'm assuming it's because the simulated keystroke does not work if no one's logged in?
So, the question is: is there a way to "tweak" this script to make it run even when no one's logged in?
Many thanks, help would be appreciated!
Philipp