0

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:

  1. Not crash and exit gracefully.
  2. Suppress the Outlook warning and create the message (preferred).

All the Mail clients are Outlook 2010 running on Windows XP or Windows 7.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
software is fun
  • 7,286
  • 18
  • 71
  • 129

1 Answers1

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.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78