'Crash when user clicks DENY
I am running this VBScript inside an HTA application:
Sub CustomMailMessage()
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.Recipients.Add("[email protected]") ' crashing here if deny
objMail.Subject = UCase("Phone Correction")
objMail.HTMLBody = GenerateEmailBody
objMail.Body = "My New Number Is: "
objMail.Display
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^+{END}", True
WshShell.SendKeys "{END}", True
Set OutApp = Nothing
End Sub
A popup appears asking the user to click ALLOW or DENY.
If ALLOW is clicked, my script works. If DENY is clicked, it crashes.
Is there a way to do one of the following:
- Not crash and exit gracefully.
- Suppress the Outlook warning and create the message (preferred).
All the Mail clients are Outlook 2010 running on Windows XP or Windows 7.
Solution 1:[1]
You need to either install an up-to-date version of antivirus software (if you can control the client environment) or bypass the Outlook Object Model (e.g. using Redemption - I am its author).
See http://www.outlookcode.com/article.aspx?id=52 for your options.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
