![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi all,
I found a code on this site to save attachment to a set directroy. Works wonderfully. Thank you. Now if I only can link a specific oulook rules to run this Macro automatically every time it processes a new item? Help Please. |
Ads |
#2
|
|||
|
|||
![]()
Rules support a "run a script" action, which uses not an external script but 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 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 -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Sid" wrote in message ... Hi all, I found a code on this site to save attachment to a set directroy. Works wonderfully. Thank you. Now if I only can link a specific oulook rules to run this Macro automatically every time it processes a new item? Help Please. |
#3
|
|||
|
|||
![]()
Sue thank you for addressing my Question.
I am kinda new to VB and did not get what you meant by below. Did you mean that I should edit the rule to run the script below? if so, how can I setup this script? "Sue Mosher [MVP-Outlook]" wrote: Rules support a "run a script" action, which uses not an external script but 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 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 -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Sid" wrote in message ... Hi all, I found a code on this site to save attachment to a set directroy. Works wonderfully. Thank you. Now if I only can link a specific oulook rules to run this Macro automatically every time it processes a new item? Help Please. |
#4
|
|||
|
|||
![]()
The procedure I posted is an example of the structure required to run VBA code from a rule, by invoking the "run a script" rule action. Specifically, the procedure needs a MailItem or MeetingItem as its argument, and that is the item that the code works with. You would need to use a similarly-structured procedure, substituting your code to work on a specific MailItem for the code below that works with the msg object. In other words, put your own code after the "do stuff with msg" comment, using msg as your MailItem object.
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Sid" wrote in message ... Sue thank you for addressing my Question. I am kinda new to VB and did not get what you meant by below. Did you mean that I should edit the rule to run the script below? if so, how can I setup this script? "Sue Mosher [MVP-Outlook]" wrote: Rules support a "run a script" action, which uses not an external script but 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 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 "Sid" wrote in message ... Hi all, I found a code on this site to save attachment to a set directroy. Works wonderfully. Thank you. Now if I only can link a specific oulook rules to run this Macro automatically every time it processes a new item? Help Please. |
#5
|
|||
|
|||
![]()
Sue. It worked. A Million Thanks.
"Sue Mosher [MVP-Outlook]" wrote: The procedure I posted is an example of the structure required to run VBA code from a rule, by invoking the "run a script" rule action. Specifically, the procedure needs a MailItem or MeetingItem as its argument, and that is the item that the code works with. You would need to use a similarly-structured procedure, substituting your code to work on a specific MailItem for the code below that works with the msg object. In other words, put your own code after the "do stuff with msg" comment, using msg as your MailItem object. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Sid" wrote in message ... Sue thank you for addressing my Question. I am kinda new to VB and did not get what you meant by below. Did you mean that I should edit the rule to run the script below? if so, how can I setup this script? "Sue Mosher [MVP-Outlook]" wrote: Rules support a "run a script" action, which uses not an external script but 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 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 "Sid" wrote in message ... Hi all, I found a code on this site to save attachment to a set directroy. Works wonderfully. Thank you. Now if I only can link a specific oulook rules to run this Macro automatically every time it processes a new item? Help Please. |
#6
|
|||
|
|||
![]()
I have sought to learn the structure required to run a rule from VBA
code. Has anyone done that (short of key-stuffing)? On Jul 26, 2:30 pm, "Sue Mosher [MVP-Outlook]" wrote: The procedure I posted is an example of the structure required to run VBA code from a rule, by invoking the "run a script" rule action. |
#7
|
|||
|
|||
![]()
Outlook 2007 is the first version with the capability to run a rule programmatically. Code sample at http://www.outlookcode.com/codedetail.aspx?id=1266
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 wrote in message oups.com... I have sought to learn the structure required to run a rule from VBA code. Has anyone done that (short of key-stuffing)? On Jul 26, 2:30 pm, "Sue Mosher [MVP-Outlook]" wrote: The procedure I posted is an example of the structure required to run VBA code from a rule, by invoking the "run a script" rule action. |
#8
|
|||
|
|||
![]()
Thank you for your clear answer, Sue.
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Send link to item using Folder Assistant rule | sriramna | Outlook - Using Forms | 6 | March 25th 07 06:22 PM |
Server-side rule with script or macro | Brian Canner | Outlook and VBA | 1 | February 12th 07 07:59 PM |
runninng macro when a rule is hit | [email protected] | Outlook and VBA | 1 | November 1st 06 03:31 PM |
How do I link a macro to a CommandButton in a custom form, want us | Capone2377 | Outlook - Using Forms | 1 | February 5th 06 01:15 AM |
Create a macro that runs from a Rule | CF_business_analyst | Outlook and VBA | 8 | January 13th 06 06:12 PM |