WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Running a Macro when email arrives

 
Goto page Previous  1, 2
   Home -> Office -> Programming VBA RSS
Next:  Side by Side Calendar View  
Author Message
BenL712

External


Since: Oct 07, 2005
Posts: 1



(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!!
> >>
>
Back to top
Login to vote
Sue Mosher [MVP-Outlook]

External


Since: Feb 11, 2005
Posts: 6513



(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?)

The pages at http://www.outlookcode.com/d/code/zaphtml.htm and http://www.outlookcode.com/d/code/quarexe.htm provide examples of routines that run whenever a new message hits the Inbox. That would be the preferred Outlook 2000 solution.

--
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


"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!!
>> >>
>>
Back to top
Login to vote
Irwin Quintana

External


Since: Sep 23, 2008
Posts: 1



(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.
Back to top
Login to vote
Rob Girard

External


Since: Jul 09, 2009
Posts: 1



(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?

Thanks

Rob

url:http://www.ureader.com/msg/1081942.aspx
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Goto page Previous  1, 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
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support