PC Review


Reply
Thread Tools Rate Thread

Macro to sttart each time, a new mail arrives in a certain folder

 
 
=?Utf-8?B?VG9iaWFzIFI=?=
Guest
Posts: n/a
 
      12th Nov 2005
Hello,

I'm looking for a reliable way which automatically runs a given macro every
time, a new eMail arrives in a given folder.

From all I know there is the newMail event - but as far as I know it is not
fully reliable.

Does anyone know of any reliable alternative?

Any help is greatly appreciated :-)

Best regards,
Tobias.


 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      13th Nov 2005
Outlook version? Are you putting the incoming message in the folder with a rule?

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


"Tobias R" <(E-Mail Removed)> wrote in message news:660E6AF6-A0A2-49C7-9487-(E-Mail Removed)...
> Hello,
>
> I'm looking for a reliable way which automatically runs a given macro every
> time, a new eMail arrives in a given folder.
>
> From all I know there is the newMail event - but as far as I know it is not
> fully reliable.
>
> Does anyone know of any reliable alternative?
>
> Any help is greatly appreciated :-)
>
> Best regards,
> Tobias.
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9iaWFzIFI=?=
Guest
Posts: n/a
 
      13th Nov 2005
Hi Sue,

thanks a lot for your quick reply.

Outlook 2003, eMails are put into folder by rule (if phrase xyz is in
subject, then move eMail in folder abc...)

"Sue Mosher [MVP-Outlook]" wrote:

> Outlook version? Are you putting the incoming message in the folder with a rule?
>
> --
> 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
>
>
> "Tobias R" <(E-Mail Removed)> wrote in message news:660E6AF6-A0A2-49C7-9487-(E-Mail Removed)...
> > Hello,
> >
> > I'm looking for a reliable way which automatically runs a given macro every
> > time, a new eMail arrives in a given folder.
> >
> > From all I know there is the newMail event - but as far as I know it is not
> > fully reliable.
> >
> > Does anyone know of any reliable alternative?
> >
> > Any help is greatly appreciated :-)
> >
> > Best regards,
> > Tobias.
> >
> >

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      13th Nov 2005
In that scenario, you could also add a "run a script" action to the rule. 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.

You may want to include the code to move the item in the VBA procedure rather than including it as a separate action on that rule. I'm not sure how well mixing rule actions and a VBA procedure will work.

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


"Tobias R" <(E-Mail Removed)> wrote in message news:999A4DF3-61D8-4953-BCC8-(E-Mail Removed)...
> Hi Sue,
>
> thanks a lot for your quick reply.
>
> Outlook 2003, eMails are put into folder by rule (if phrase xyz is in
> subject, then move eMail in folder abc...)
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> Outlook version? Are you putting the incoming message in the folder with a rule?
>>
>> --
>> 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
>>
>>
>> "Tobias R" <(E-Mail Removed)> wrote in message news:660E6AF6-A0A2-49C7-9487-(E-Mail Removed)...
>> > Hello,
>> >
>> > I'm looking for a reliable way which automatically runs a given macro every
>> > time, a new eMail arrives in a given folder.
>> >
>> > From all I know there is the newMail event - but as far as I know it is not
>> > fully reliable.
>> >
>> > Does anyone know of any reliable alternative?
>> >
>> > Any help is greatly appreciated :-)
>> >
>> > Best regards,
>> > Tobias.
>> >
>> >

>>

 
Reply With Quote
 
=?Utf-8?B?VG9iaWFzIFI=?=
Guest
Posts: n/a
 
      13th Nov 2005
Hi Sue,

thanks a lot again.

It sound like a good idea to "simply" add the "run a script" action to my
existing rule. If I understood you correctly, I would need to enhance my rule
by pointing to the respective script. Is that right?

Does that script have to be located anywhere in particular? Could I just
include it in "ThisOutlookSession"?

My original problem was that I had defined a rule (which apparently always
worked if a new mail arrived in my postbox) and that I had written a script -
which sometimes didn't start. So I was looking for a solution to this
problem.

From all I can tell, your "first" method could be a solution to this -
provided mixing code and a rule does work...

However, if I wanted to implement your second suggestion, I would again have
to write a script only. And wouldn't that put me once again in the same
position that I am in now - which means I'd run the risk of the script not
always starting automatically?

Thank you very much for any help.

Best regards,
Tobias.
 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      14th Nov 2005
The VBA procedure that you want the rule to run can be in either ThisOutlookSession or a normal module that you've added. The Rules Wizard will display an error if you create a "run a script" rule and try to save it without pointing to the VBA procedure you want to run.

I was not suggesting mixing code and a rule. I was suggesting that you not mix normal rule actions and a "run a script" action. Instead, have the "script" perform all the actions that you want to take on the message. As long as the rule fires, the "script" will run.

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


"Tobias R" <(E-Mail Removed)> wrote in message news:17AD7A93-FDAA-43F2-99AE-(E-Mail Removed)...
> Hi Sue,
>
> thanks a lot again.
>
> It sound like a good idea to "simply" add the "run a script" action to my
> existing rule. If I understood you correctly, I would need to enhance my rule
> by pointing to the respective script. Is that right?
>
> Does that script have to be located anywhere in particular? Could I just
> include it in "ThisOutlookSession"?
>
> My original problem was that I had defined a rule (which apparently always
> worked if a new mail arrived in my postbox) and that I had written a script -
> which sometimes didn't start. So I was looking for a solution to this
> problem.
>
> From all I can tell, your "first" method could be a solution to this -
> provided mixing code and a rule does work...
>
> However, if I wanted to implement your second suggestion, I would again have
> to write a script only. And wouldn't that put me once again in the same
> position that I am in now - which means I'd run the risk of the script not
> always starting automatically?
>
> Thank you very much for any help.
>
> Best regards,
> Tobias.

 
Reply With Quote
 
=?Utf-8?B?VG9iaWFzIFI=?=
Guest
Posts: n/a
 
      14th Nov 2005
Hi again,

I think you misunderstood me. I took the "run a script" option as option one
(which I though you did NOT prefer, since it would mean mixing a script & a
rule).

A second option (which I thought was the one you preferred) was to not use
any rule but write a macro that does the job of both (i.e. the rule and the
script).

However, my original problem was / is that at present I have problems with a
macro that does NOT automatically start every time a new mail enters. And I
fear that if I used option two, this problem could persist?!




"Sue Mosher [MVP-Outlook]" wrote:

> The VBA procedure that you want the rule to run can be in either ThisOutlookSession or a normal module that you've added. The Rules Wizard will display an error if you create a "run a script" rule and try to save it without pointing to the VBA procedure you want to run.
>
> I was not suggesting mixing code and a rule. I was suggesting that you not mix normal rule actions and a "run a script" action. Instead, have the "script" perform all the actions that you want to take on the message. As long as the rule fires, the "script" will run.
>
> --
> 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
>
>
> "Tobias R" <(E-Mail Removed)> wrote in message news:17AD7A93-FDAA-43F2-99AE-(E-Mail Removed)...
> > Hi Sue,
> >
> > thanks a lot again.
> >
> > It sound like a good idea to "simply" add the "run a script" action to my
> > existing rule. If I understood you correctly, I would need to enhance my rule
> > by pointing to the respective script. Is that right?
> >
> > Does that script have to be located anywhere in particular? Could I just
> > include it in "ThisOutlookSession"?
> >
> > My original problem was that I had defined a rule (which apparently always
> > worked if a new mail arrived in my postbox) and that I had written a script -
> > which sometimes didn't start. So I was looking for a solution to this
> > problem.
> >
> > From all I can tell, your "first" method could be a solution to this -
> > provided mixing code and a rule does work...
> >
> > However, if I wanted to implement your second suggestion, I would again have
> > to write a script only. And wouldn't that put me once again in the same
> > position that I am in now - which means I'd run the risk of the script not
> > always starting automatically?
> >
> > Thank you very much for any help.
> >
> > Best regards,
> > Tobias.

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      14th Nov 2005
> A second option (which I thought was the one you preferred) was to not use
> any rule but write a macro that does the job of both (i.e. the rule and the
> script).


Yes, sort of. The code would be part of the rule, through the "run a script" action.

> However, my original problem was / is that at present I have problems with a
> macro that does NOT automatically start every time a new mail enters. And I
> fear that if I used option two, this problem could persist?!


That's why I suggested that you switch to a "run a script" rule and let the rule handle running the script.
>


 
Reply With Quote
 
=?Utf-8?B?VG9iaWFzIFI=?=
Guest
Posts: n/a
 
      14th Nov 2005
Thanks - seems I misunderstood you.

I quite like the run-a-script idea and I'll test it :-)

As the rule hasn't failed so far, I think (and hope...) it's the solution I
was after :-)

"Sue Mosher [MVP-Outlook]" wrote:

> > A second option (which I thought was the one you preferred) was to not use
> > any rule but write a macro that does the job of both (i.e. the rule and the
> > script).

>
> Yes, sort of. The code would be part of the rule, through the "run a script" action.
>
> > However, my original problem was / is that at present I have problems with a
> > macro that does NOT automatically start every time a new mail enters. And I
> > fear that if I used option two, this problem could persist?!

>
> That's why I suggested that you switch to a "run a script" rule and let the rule handle running the script.
> >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically print e-mail attachement when e-mail arrives =?Utf-8?B?bGF3YXR0ZXJz?= Microsoft Outlook Discussion 0 30th Mar 2007 07:34 PM
Read subject when New Mail arrives-Sub Folder =?Utf-8?B?QXZhZGl2ZWxhbiBUQ1M=?= Microsoft Outlook VBA Programming 3 14th Nov 2006 02:58 AM
Folder expansion when new mail arrives is failing Colin M. McGroarty Microsoft Outlook 3 7th Oct 2005 05:54 PM
Folder expansion when new mail arrives is failing Colin M. McGroarty Microsoft Outlook Discussion 3 7th Oct 2005 05:54 PM
Folder Status Does Not Update When New Mail Arrives Rafael Microsoft Outlook 0 13th May 2004 08:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 PM.