(Msg. 1) Posted: Wed Aug 10, 2005 6:59 am
Post subject: Running a Macro when email arrives Archived from groups: microsoft>public>outlook>program_vba (more info?)
I want to run a macro when an email with a specific Subject arrives, how can
I check every email that comes in?
(Msg. 2) Posted: Wed Aug 10, 2005 10:08 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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
--
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. 3) Posted: Wed Aug 10, 2005 10:08 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Thanks Sue,
another question: How will it execute each time a new email arrives?
"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. 4) Posted: Wed Aug 10, 2005 11:04 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Set whatever conditions you like in the rules wizard, no doubt a condition to check the subject for particular text, given what you described originally as your scenario.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"mecg96" <mecg96.DeleteThis@discussions.microsoft.com> wrote in message news:57AA7C3D-CB22-4FE3-982A-3F9BC8E57F65@microsoft.com...
> Thanks Sue,
>
> another question: How will it execute each time a new email arrives?
>
>
> "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.DeleteThis@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. 5) Posted: Wed Aug 10, 2005 11:04 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Thanks!! This was really helpful
"Sue Mosher [MVP-Outlook]" wrote:
> Set whatever conditions you like in the rules wizard, no doubt a condition to check the subject for particular text, given what you described originally as your scenario.
>
> --
> 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:57AA7C3D-CB22-4FE3-982A-3F9BC8E57F65@microsoft.com...
> > Thanks Sue,
> >
> > another question: How will it execute each time a new email arrives?
> >
> >
> > "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. 6) Posted: Fri Aug 19, 2005 9:12 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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.DeleteThis@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. 7) Posted: Tue Aug 23, 2005 9:12 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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. 8) Posted: Mon Sep 05, 2005 7:47 am
Post subject: Re: Running a Macro when email arrives [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Sue,
Apologies for not responding sooner - I didn't get a notification (maybe our
spam filters are overzelous) and haven't had a chance to check the site until
today.
Thanks very much for your suggestion which, although a little daunting for a
self-taught novice, looks feasible. I'll give it a try, and if you hear
nothing more from me you may assume
a) that it worked, and
b) that I'm grateful!
All times are: Eastern Time (US & Canada) (change) Goto page 1, 2
Page 1 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