"Run a script" rule triggers but script does not execute

T

Trey Shaffer

I am attempting to use the "Run a script" action in an Outlook 2003 rule.

The script contents appears to be valid, with the requisite MailItem. The
subroutines are recognized, and selectable, in the Rules Wizard. Code
below...

The rule is being triggered. If I add some other built in action action,
Play a Sound, etc., to the rule, it occurs.

Following are two code bits. The first is from Sue Mosher. The second is
just a minimalist fragment to produce a visible result, the MsgBox. Niether
one produces the expected message box.

Fragment 1 _________________________________________
Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
' do stuff with olMail, e.g.
MsgBox olMail.Body

Set olMail = Nothing
Set olNS = Nothing
End Sub


Fragment 2 __________________________________________
Sub Test(objMyMail As MailItem)
MsgBox "Hello World"
End Sub


Your help appreciated...
 
S

Sue Mosher [MVP-Outlook]

Does other VBA code run? What is your setting in Tools | Macro Security?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Trey Shaffer

Yes, Macro Security setting was "High." Changed to "Low" and code ran...
I'm guessing I can use the SelfCert.exe to put a signature on this when I'm
ready to deploy it...

Thanks Sue

Does other VBA code run? What is your setting in Tools | Macro Security?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Deploy it? You realize that Outlook VBA code was never designed to be deployed to other people, right?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Trey Shaffer

Perhaps I should have said, "Install it on the two workstations that will
use it."


Deploy it? You realize that Outlook VBA code was never designed to be
deployed to other people, right?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

As long as you understand that there's no way to do that short of export/import and the VBA code project, especially when you're using rules to run procedures, can become corrupted, we'll feel you've been fairly warned.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Trey Shaffer

When someone tells me something will work, I always hope their right and
test it. When someone tells me something won't work, I usually take that at
face value.

I am familiar with the module export/import process, and it seems functional
for limited, manual distribution. I guess my concern is more with the
second part of your statement about corruption. I was planning to run this
rule/process on a"lights-out" machine. The function is not mission
critical, but a few people would say it is important to their job function.

Any more suggestions or war stories you would care to share?




As long as you understand that there's no way to do that short of
export/import and the VBA code project, especially when you're using rules
to run procedures, can become corrupted, we'll feel you've been fairly
warned.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

I have myself seen a VBAProject.otm file go belly-up while running a "run from script" rule and have fielded a couple of reports from others who have also seen that happen. The VBAProject.otm files in question were unrecoverable. Moral of the story: Keep backups.

Outlook is not really designed to run any kind of code in an unattended environment. As a client application, there are just too many scenarios where execution could be blocked by modal UI that Outlook displays. So, you'll certainly want to keep a close eye on any such machine. And, in the long run, you might want to consider other ways of accomplishing the same goal (whatever that is).

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top