(Msg. 9) Posted: Fri Oct 07, 2005 8:15 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: microsoft>public>outlook>program_vba (more info?)
Is there any way to accomplish the same thing in Outlook 2000?
"Sue Mosher [MVP-Outlook]" wrote:
> Your "macro" needs to be in the format I described earlier -- a Public Sub with a single MailItem argument. In other words, the procedure structure is not the same as that for a macro that you can run from a toolbar button (which is a Public but argumentless Sub).
> --
> Sue Mosher, Outlook MVP
> Author of
> Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx >
>
> "Giles" <Giles RemoveThis @discussions.microsoft.com> wrote in message news:86D0B5EB-ABFF-4D59-AB07-3459BF17F86F@microsoft.com...
> > Sue,
> >
> > Can I step back a bit on to a more basic level?
> >
> > I've got an Outlook macro which I've successfully operated via a toolbar
> > button to check that it works. Like mecg96, I want it to run when a rule is
> > processed. I've created the rule up to the point of specifying the action to
> > take.
> >
> > However, when I select "run a script" here, I get a window entitled "Select
> > Script" with an empty box underneath; there's nothing to click on in the box
> > and the only options I have are two buttons: OK and Close.
> >
> > How do I link my macro to the rule? Should I be putting my macro script
> > somewhere special rather than in the "ThisOutlookSession" procedure in VBA?
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> A "run a script" rule action takes a MailItem or MeetingItem as its parameter, then uses that item in the code:
> >>
> >> 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.Subject
> >>
> >> Set olMail = Nothing
> >> Set olNS = Nothing
> >> End Sub
> >>
> >> See http://www.outlookcode.com/d/code/zaphtml.htm#ol2002 for another example and alternative approaches.
> >>
> >> --
> >> Sue Mosher, Outlook MVP
> >> Author of
> >> Microsoft Outlook Programming - Jumpstart for
> >> Administrators, Power Users, and Developers
> >> http://www.outlookcode.com/jumpstart.aspx > >>
> >>
> >> "mecg96" <mecg96 RemoveThis @discussions.microsoft.com> wrote in message news:602581A1-8EDC-4AF9-98B3-14424581AEA1@microsoft.com...
> >> >I want to run a macro when an email with a specific Subject arrives, how can
> >> > I check every email that comes in?
> >> >
> >> > Thanks!!
> >>
>
(Msg. 10) Posted: Fri Oct 07, 2005 1:27 pm
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
"BenL712" <BenL712.TakeThisOut@discussions.microsoft.com> wrote in message news:8F354B69-97C6-463B-9764-901D37F87391@microsoft.com...
> Is there any way to accomplish the same thing in Outlook 2000?
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> Your "macro" needs to be in the format I described earlier -- a Public Sub with a single MailItem argument. In other words, the procedure structure is not the same as that for a macro that you can run from a toolbar button (which is a Public but argumentless Sub).
>>
>> "Giles" <Giles.TakeThisOut@discussions.microsoft.com> wrote in message news:86D0B5EB-ABFF-4D59-AB07-3459BF17F86F@microsoft.com...
>> > Sue,
>> >
>> > Can I step back a bit on to a more basic level?
>> >
>> > I've got an Outlook macro which I've successfully operated via a toolbar
>> > button to check that it works. Like mecg96, I want it to run when a rule is
>> > processed. I've created the rule up to the point of specifying the action to
>> > take.
>> >
>> > However, when I select "run a script" here, I get a window entitled "Select
>> > Script" with an empty box underneath; there's nothing to click on in the box
>> > and the only options I have are two buttons: OK and Close.
>> >
>> > How do I link my macro to the rule? Should I be putting my macro script
>> > somewhere special rather than in the "ThisOutlookSession" procedure in VBA?
>> >
>> > "Sue Mosher [MVP-Outlook]" wrote:
>> >
>> >> A "run a script" rule action takes a MailItem or MeetingItem as its parameter, then uses that item in the code:
>> >>
>> >> 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.Subject
>> >>
>> >> Set olMail = Nothing
>> >> Set olNS = Nothing
>> >> End Sub
>> >>
>> >> See http://www.outlookcode.com/d/code/zaphtml.htm#ol2002 for another example and alternative approaches.
>> >>
>> >> --
>> >> Sue Mosher, Outlook MVP
>> >> Author of
>> >> Microsoft Outlook Programming - Jumpstart for
>> >> Administrators, Power Users, and Developers
>> >> http://www.outlookcode.com/jumpstart.aspx >> >>
>> >>
>> >> "mecg96" <mecg96.TakeThisOut@discussions.microsoft.com> wrote in message news:602581A1-8EDC-4AF9-98B3-14424581AEA1@microsoft.com...
>> >> >I want to run a macro when an email with a specific Subject arrives, how can
>> >> > I check every email that comes in?
>> >> >
>> >> > Thanks!!
>> >>
>>
(Msg. 11) Posted: Tue Sep 23, 2008 10:27 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Great code, you save me from hours of work!
Regards from Mexico.
(Msg. 12) Posted: Thu Jul 09, 2009 8:05 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Hi Sue,
Your script is very useful and I have mange to create this to flash up with
a msg box when the email arrives with a specific subject.
Is there a way I can use this same code to open an Excel document?
All times are: Eastern Time (US & Canada) (change) Goto page Previous1, 2
Page 2 of 2
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum