I am trying to automate autosending Outlook emails with VBScript. I tried following ways:
- Sending emails programmatically with Mail.Send command in VBScript
Attempting to send EMails programmatically does not seem to work due to security reasons. Here is my code sample:
Set WshShell = WScript.CreateObject("WScript.Shell")
Set ol=CreateObject("Outlook.Application")
Set Mail=ol.CreateItem(0)
Mail.to= "xx.xxx.com"
Mail.Subject = "AUTOMATED UPDATE: is ready to be booked"
Mail.HTMLBody = "please see attachments... :)"
Mail.Display
Mail.send
ol.quit
Set Mail = Nothing
Set ol = Nothing
POP-UP BLOCK I GET:
Sending Mails with SendKeys Method (working but unstable method) Here is my code sample:
Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.run "outlook" Set ol=CreateObject("Outlook.Application") Set Mail=ol.CreateItem(0) Mail.to= "xxxx.com" Mail.Subject = "AUTOMATED UPDATE: "&file_name&" is ready to be booked" Mail.HTMLBody = "please see attachments... :)" Mail.Attachments.add "xxxx" Mail.Display WshShell.AppActivate(Mail.Subject&" - Message (HTML)") WshShell.SendKeys "%{s}",1 WScript.Sleep 40000 ol.quit Set Mail = Nothing Set ol = Nothing WshShell.Run "taskkill /im outlook.exe", , True
This method works, but supposes that no one should interrupt the process and klick something. It is very unstable and that's why I am looking for other opportunities.
Having googled till 999999 page :) of Google Search, I found the following options, but neither of them is workable in my case:
- Use Redemption - acc. to company policy I am not allowed to use third party application
- Use ClickYes - acc. to company policy I am not allowed to use third party application
- Send Emails through CDO - I cannot connect to SMTP Server because does not know the password therefrom and not authorized to get it
- I also looked if it is possible to send keys on the background window - unfortunately it is NOT possible.
- Going to TrustCenter of Outlook and change setting - it is not allowed to do that acc. to company policy
Can anyone advise some other workaround?