![]() |
What folder does Outlook 2007 use for scripts?
I have a script (.vbs) which I wish to run upon receiving certain
messages. What is the default directory path in which to place the script so that I may invoke it with a rule? Thanks! |
What folder does Outlook 2007 use for scripts?
Outlook doesn't use .vbs scripts with rules. A "run a script" rule action uses not an external script but a VBA procedure with a MailItem or MeetingItem as its parameter. That item is processed by the code. Here's an example:
Sub RunAScriptRuleRoutine(MyMail As MailItem) Dim strID As String Dim olNS As Outlook.NameSpace Dim msg As Outlook.MailItem Dim rply as Outlook.MailItem strID = MyMail.EntryID Set olNS = Application.GetNamespace("MAPI") Set msg = olNS.GetItemFromID(strID) ' do stuff with msg, e.g. Set rply = msg.Reply rply.Body = "What you want the reply to say." rply.To = ; " rply.Send Set msg = Nothing Set rply = Nothing Set olNS = Nothing End Sub For Outlook VBA basics, see http://outlookcode.com/article.aspx?id=49 For another example of a "run a script" rule actions, see: http://www.outlookcode.com/codedetail.aspx?id=1494 CAUTION: Using this technique has been known to result in corrupt VBA code. Be sure to export your code modules or back up the VBAProject.otm file. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "High Desert" wrote in message ... I have a script (.vbs) which I wish to run upon receiving certain messages. What is the default directory path in which to place the script so that I may invoke it with a rule? Thanks! |
What folder does Outlook 2007 use for scripts?
On Fri, 27 Jun 2008 15:21:23 -0400, "Sue Mosher [MVP-Outlook]"
wrote: Outlook doesn't use .vbs scripts with rules. A "run a script" rule action uses not an external script but a VBA procedure with a MailItem or MeetingItem as its parameter. That item is processed by the code. Here's an example: Sub RunAScriptRuleRoutine(MyMail As MailItem) Dim strID As String Dim olNS As Outlook.NameSpace Dim msg As Outlook.MailItem Dim rply as Outlook.MailItem strID = MyMail.EntryID Set olNS = Application.GetNamespace("MAPI") Set msg = olNS.GetItemFromID(strID) ' do stuff with msg, e.g. Set rply = msg.Reply rply.Body = "What you want the reply to say." rply.To = ; " rply.Send Set msg = Nothing Set rply = Nothing Set olNS = Nothing End Sub For Outlook VBA basics, see http://outlookcode.com/article.aspx?id=49 For another example of a "run a script" rule actions, see: http://www.outlookcode.com/codedetail.aspx?id=1494 CAUTION: Using this technique has been known to result in corrupt VBA code. Be sure to export your code modules or back up the VBAProject.otm file. Thanks for the info and pointers. Guess that I need to do a re-write! I was so close, so close .... ;-) |
All times are GMT +1. The time now is 11:37 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com