I am running this VBScript inside an HTA application:
Sub CustomMailMessage()
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.Recipients.Add("myemail@domain.com") ' 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.