Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Rules & Scripts.

Status
Not open for further replies.

brigmar

Programmer
Mar 21, 2006
414
US
(Also posted this in the "Office" forum, but the error seems to be with the VBA section, so here goes...)

I have Outlook 2003, and I'm trying to set up a script to deal with messages from a particular cellphone.
I have set up a rule that can identify and flag those messages, which was easy enough. The next step is to run a script based off of that message, which seemed easy enough:

Tools -> Macro -> Visual Basic Editor
Project1
-- Microsoft Office Outlook Objects
----- ThisOutlookSession

Code:
Sub MyCustomAutomationRule( Item as Outlook.MailItem )
   MsgBox "Test"
End Sub
(Obviously I would interact with the Item object for the real thing.)

Save and Compile Project1.

I go back to the Rule Editor and add "run a script" to the rule. Select "Project1.ThisOutlookSession.MyCustomAutomationRule", and run the rule on a message I have in my Inbox.

Now the rule runs, flags the message as before, and then gives me an error dialog: "The operation failed".

I try to set a breakpoint in the Visual Basic Editor, but nothing happens.

In the end, here's what I want to do:
* Identify messages from cellphone X (can do)
* Extract and Parse the body of the message (this problem)
* Pass the parsed message to a command line app which will do "the intelligent stuff"

Am I even on the right track ? There is of course the ability to "start an application" in the rules editor but that doesn't allow me to pass the body of the message as a parameter, hence trying to write a VBA script to do that work.
 
add "run a script" to the rule
Are you sure a "script" is a VBA macro instead of a VBS script ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I launched the VB editor from within Outlook and created the above subroutine.

When adding the script to the rule (from the rules wizard, mind), I am given a dialog that only allows me to choose Subs that match the correct signature (ie... have a single Outlook.MailItem parameter). I choose the only option given to me; "Project1.ThisOutlookSession.MyCustomAutomationRule".

I believe I followed the information at (How to create a script for the Rules Wizard in Outlook)
 
Does the project compiles properly ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yes. It compiles without any warnings. After all, it is just one 'Sub' that displays a MsgBox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top