A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

rules to run macro



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 26th 07, 06:14 PM posted to microsoft.public.outlook
DSPettit
external usenet poster
 
Posts: 3
Default rules to run macro

Hello all,

Is there a way to cause a rule to run a macro? I have a macro written that
runs fine if invoked manually, but I don't seem to be able to find a way to
cause a rule to run a macro.

Thanks,
Doug


Ads
  #2  
Old April 26th 07, 06:58 PM posted to microsoft.public.outlook
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default rules to run macro

A "run a script" rule action actually can run a VBA procedure with a MailItem or MeetingItem as its parameter. That item is processed by the code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem

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

Set msg = Nothing
Set olNS = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"DSPettit" wrote in message ...
Hello all,

Is there a way to cause a rule to run a macro? I have a macro written that
runs fine if invoked manually, but I don't seem to be able to find a way to
cause a rule to run a macro.

Thanks,
Doug


  #3  
Old April 27th 07, 02:42 PM posted to microsoft.public.outlook
DSPettit
external usenet poster
 
Posts: 3
Default rules to run macro

Sue,

Thanks for the help. I see what you are saying. Unfortunately, I am running
Outlook 2000 SP-3, and "run a script" is not available. I am guessing that
my best option is to upgrade to something more current.

Any other thoughts or ideas?

Thanks,
Doug


"Sue Mosher [MVP-Outlook]" wrote in message
...
A "run a script" rule action actually can run a VBA procedure with a
MailItem or MeetingItem as its parameter. That item is processed by the
code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem

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

Set msg = Nothing
Set olNS = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"DSPettit" wrote in message
...
Hello all,

Is there a way to cause a rule to run a macro? I have a macro written that
runs fine if invoked manually, but I don't seem to be able to find a way

to
cause a rule to run a macro.

Thanks,
Doug




  #4  
Old April 27th 07, 04:06 PM posted to microsoft.public.outlook
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default rules to run macro

Either that or use the ItemsAdd different approach; see http://www.outlookcode.com/d/code/zaphtml.htm

Now you know that you really need to include your Outlook version whenever you post here.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"DSPettit" wrote in message ...
Sue,

Thanks for the help. I see what you are saying. Unfortunately, I am running
Outlook 2000 SP-3, and "run a script" is not available. I am guessing that
my best option is to upgrade to something more current.

Any other thoughts or ideas?

Thanks,
Doug


"Sue Mosher [MVP-Outlook]" wrote in message
...
A "run a script" rule action actually can run a VBA procedure with a
MailItem or MeetingItem as its parameter. That item is processed by the
code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem

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

Set msg = Nothing
Set olNS = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"DSPettit" wrote in message
...
Hello all,

Is there a way to cause a rule to run a macro? I have a macro written that
runs fine if invoked manually, but I don't seem to be able to find a way

to
cause a rule to run a macro.

Thanks,
Doug




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to run Rules in batch bman342 Outlook and VBA 4 March 14th 07 06:16 PM
Rules for moving outside mails to specific folder (Macro) Moshico Outlook and VBA 1 January 22nd 07 02:03 PM
OL2003: Need macro to run all rules [email protected] Outlook - General Queries 3 September 4th 06 03:54 AM
Rules an macro Gerd Neumann Outlook and VBA 4 May 17th 06 09:48 PM
Execute rules with a macro Gerd Neumann Outlook and VBA 1 May 11th 06 09:50 PM


All times are GMT +1. The time now is 02:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.