How to catch Message Move Event.

  • Thread starter Ashutosh Jogdande
  • Start date
Status
Not open for further replies.
A

Ashutosh Jogdande

Hi All,

Is there any way to Catch Message Move event through outlook addin, when

message/s are moved by using Email-rules or to Archive folders?

I am able to do this on manual message move by catching ItemRemove on

selected folder.

But while running a rule I am not getting Message Move/Remove event.

Code :

outlookExplorer.CurrentFolder.Items.ItemRemove += new

Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);

Thanks in advance,

Ashutosh
 
K

Ken Slovak - [MVP - Outlook]

That would partially depend on what version of Outlook. For Outlook 2003 and

earlier you only would have the Items.ItemAdd() and ItemRemove() events on

the destination and source folders to rely on. In Outlook 2007 you have the

Folder.BeforeItemMove() event you could also try.

"Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message

news:eiuZfRyKKHA.4432@TK2MSFTNGP02.phx.gbl...
> Hi All,

> Is there any way to Catch Message Move event through outlook addin,
> when message/s are moved by using Email-rules or to Archive folders?

> I am able to do this on manual message move by catching ItemRemove on
> selected folder.
> But while running a rule I am not getting Message Move/Remove event.

> Code :
> outlookExplorer.CurrentFolder.Items.ItemRemove += new
> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);

> Thanks in advance,
> Ashutosh

>
 
A

Ashutosh Jogdande

Hi Ken,

Thanks for quick reply.

By adding ItemRemove event handler on outlookExplorer.CurrentFolder I am

able to catch the event.

But How to add event handler for all folders when addin gets loaded, as we

want to catch events for the mails which are getting archived or Moved using

Email-Rules.

I have tried by adding event handler to all the folders on addin startup,

but it didn't work.

Is there any way to trap this event at Explorer level?

Here is the code :

IEnumerator enumrator = _outlookApplication.Session.Folders.GetEnumerator();

while (enumrator.MoveNext())

{

Outlook.Folder folder = (Outlook.Folder)enumrator.Current;

if (folder != null)

{

AddEventHandlers(folder);

}

}

where AddEventHandlers recursively adding event hadler to each folder.

Thanks,

Ashutosh
<kenslovak@mvps.org> wrote in message

news:%23pLmd%238KKHA.4136@TK2MSFTNGP04.phx.gbl...
> That would partially depend on what version of Outlook. For Outlook 2003
> and earlier you only would have the Items.ItemAdd() and ItemRemove()
> events on the destination and source folders to rely on. In Outlook 2007
> you have the Folder.BeforeItemMove() event you could also try.

> >

>

> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message
> news:eiuZfRyKKHA.4432@TK2MSFTNGP02.phx.gbl...
> > Hi All,
>

>> Is there any way to Catch Message Move event through outlook addin,
> > when message/s are moved by using Email-rules or to Archive folders?
>

>> I am able to do this on manual message move by catching ItemRemove on
> > selected folder.
> > But while running a rule I am not getting Message Move/Remove event.
>

>> Code :
> > outlookExplorer.CurrentFolder.Items.ItemRemove += new
> > Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);
>

>
>> Thanks in advance,
> > Ashutosh
>

>
>>

>
 
K

Ken Slovak - [MVP - Outlook]

As you can see in the Object Browser there isn't an Explorer level event you

can use.

When I need to handle multiple folders, Explorers, Items collections,

Inspectors, etc. I set up a class to handle what I need, including all

events I want to handle. Then I maintain a set of those classes in a

collection/list/whatever to keep them alive.

For ItemRemove() and/or ItemAdd() I would do a recursive search of all

folders loaded that I was interested in and grab the Items collection for

each one, setting the Items collection object in my class to that Items

collection and putting it in my list. Then the events would fire

automatically. On shutdown I'd just unwind the list collection and null out

everything.

The code you show is non-recursive, it would only return top level folders

of the NameSpace object, which would be at the Outlook Today level (top of

store). If you have only one PST or mailbox loaded you'd get exactly 1

handler installed and it would likely be useless. I'd recursively call each

Session.Folders.Item() object and dig down into those also to get all the

folders and their Items collections.

"Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message

news:ujM97W%23KKHA.6016@TK2MSFTNGP05.phx.gbl...
> Hi Ken,

> Thanks for quick reply.

> By adding ItemRemove event handler on outlookExplorer.CurrentFolder I am
> able to catch the event.

> But How to add event handler for all folders when addin gets loaded, as we
> want to catch events for the mails which are getting archived or Moved
> using Email-Rules.

> I have tried by adding event handler to all the folders on addin startup,
> but it didn't work.

> Is there any way to trap this event at Explorer level?

> Here is the code :
> IEnumerator enumrator =
> _outlookApplication.Session.Folders.GetEnumerator();
> while (enumrator.MoveNext())
> {
> Outlook.Folder folder = (Outlook.Folder)enumrator.Current;
> if (folder != null)
> {
> AddEventHandlers(folder);
> }
> }

> where AddEventHandlers recursively adding event hadler to each folder.

> Thanks,
> Ashutosh
 
D

Dmitry Streblechenko

<plug
You can do that using Redemption: it exposes RDOStore.OnMessageCreated /

OnMessageDeleted / etc events on the store level

See http://www.dimastr.com/redemption/rdo/rdostore.htm

<plug

Dmitry Streblechenko (MVP)

-

"Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message

news:ujM97W%23KKHA.6016@TK2MSFTNGP05.phx.gbl...
> Hi Ken,

> Thanks for quick reply.

> By adding ItemRemove event handler on outlookExplorer.CurrentFolder I am
> able to catch the event.

> But How to add event handler for all folders when addin gets loaded, as we
> want to catch events for the mails which are getting archived or Moved
> using Email-Rules.

> I have tried by adding event handler to all the folders on addin startup,
> but it didn't work.

> Is there any way to trap this event at Explorer level?

> Here is the code :
> IEnumerator enumrator =
> _outlookApplication.Session.Folders.GetEnumerator();
> while (enumrator.MoveNext())
> {
> Outlook.Folder folder = (Outlook.Folder)enumrator.Current;
> if (folder != null)
> {
> AddEventHandlers(folder);
> }
> }

> where AddEventHandlers recursively adding event hadler to each folder.

> Thanks,
> Ashutosh

> " - " <kenslovak@mvps.org> wrote in message
> news:%23pLmd%238KKHA.4136@TK2MSFTNGP04.phx.gbl...
> > That would partially depend on what version of Outlook. For Outlook 2003
> > and earlier you only would have the Items.ItemAdd() and ItemRemove()
> > events on the destination and source folders to rely on. In Outlook 2007
> > you have the Folder.BeforeItemMove() event you could also try.
>

>> > >

> >

>

>
>
>
>
>
>> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message
> > news:eiuZfRyKKHA.4432@TK2MSFTNGP02.phx.gbl...
> >> Hi All,
> >
>>> Is there any way to Catch Message Move event through outlook addin,
> >> when message/s are moved by using Email-rules or to Archive folders?
> >
>>> I am able to do this on manual message move by catching ItemRemove on
> >> selected folder.
> >> But while running a rule I am not getting Message Move/Remove event.
> >
>>> Code :
> >> outlookExplorer.CurrentFolder.Items.ItemRemove += new
> >> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);
> >
>>
>>> Thanks in advance,
> >> Ashutosh
> >
>>
>>>

> >


>
 
A

Ashutosh Jogdande

Hi Ken,

Thanks for detailed reply,

I did the same, only thing I am missing is maintaining a Custom Class,

instead of that I have used Global List of Outlook.MAPIFolder.

And Recursion code is inside AddEventHandlers() Method.

But it's not working :(

Her is the code missing in my last post:

Global variable List<Outlook.MAPIFolder> folders;

void AddEventHandlers(Outlook.Folder folder)

{

folders.Add(folder);

logger.Debug("Adding ItemRemove eventhandler to " + folder.Name);

folder.Items.ItemRemove += new

Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);

IEnumerator enumrator = folder. Folders.GetEnumerator();

while (enumrator.MoveNext())

{

Outlook.Folder tempFolder = (Outlook.Folder)enumrator.Current;

if (tempFolder != null)

{

AddEventHandlers(tempFolder);

}

}

}
<kenslovak@mvps.org> wrote in message

news:u4TfYs$KKHA.4004@TK2MSFTNGP05.phx.gbl...
> As you can see in the Object Browser there isn't an Explorer level event
> you can use.

> When I need to handle multiple folders, Explorers, Items collections,
> Inspectors, etc. I set up a class to handle what I need, including all
> events I want to handle. Then I maintain a set of those classes in a
> collection/list/whatever to keep them alive.

> For ItemRemove() and/or ItemAdd() I would do a recursive search of all
> folders loaded that I was interested in and grab the Items collection for
> each one, setting the Items collection object in my class to that Items
> collection and putting it in my list. Then the events would fire
> automatically. On shutdown I'd just unwind the list collection and null
> out everything.

> The code you show is non-recursive, it would only return top level folders
> of the NameSpace object, which would be at the Outlook Today level (top of
> store). If you have only one PST or mailbox loaded you'd get exactly 1
> handler installed and it would likely be useless. I'd recursively call
> each Session.Folders.Item() object and dig down into those also to get all
> the folders and their Items collections.

> >

>

> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message
> news:ujM97W%23KKHA.6016@TK2MSFTNGP05.phx.gbl...
> > Hi Ken,
>

>> Thanks for quick reply.
>

>> By adding ItemRemove event handler on outlookExplorer.CurrentFolder I am
> > able to catch the event.
>

>> But How to add event handler for all folders when addin gets loaded, as
> > we want to catch events for the mails which are getting archived or Moved
> > using Email-Rules.
>

>> I have tried by adding event handler to all the folders on addin startup,
> > but it didn't work.
>

>> Is there any way to trap this event at Explorer level?
>

>> Here is the code :
> > IEnumerator enumrator =
> > _outlookApplication.Session.Folders.GetEnumerator();
> > while (enumrator.MoveNext())
> > {
> > Outlook.Folder folder = (Outlook.Folder)enumrator.Current;
> > if (folder != null)
> > {
> > AddEventHandlers(folder);
> > }
> > }
>

>> where AddEventHandlers recursively adding event hadler to each folder.
>

>> Thanks,
> > Ashutosh

>
 
A

Ashutosh Jogdande

Thanks Dmitry,

Unfortunately we are not using redemption in this version :( .

We would possibly use in our next version...

Thanks,

Ashutosh

"Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message

news:%23gteAhFLKHA.1376@TK2MSFTNGP02.phx.gbl...
> <plug
> You can do that using Redemption: it exposes RDOStore.OnMessageCreated /
> OnMessageDeleted / etc events on the store level
> See http://www.dimastr.com/redemption/rdo/rdostore.htm
> <plug
> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message
> news:ujM97W%23KKHA.6016@TK2MSFTNGP05.phx.gbl...
> > Hi Ken,
>

>> Thanks for quick reply.
>

>> By adding ItemRemove event handler on outlookExplorer.CurrentFolder I am
> > able to catch the event.
>

>> But How to add event handler for all folders when addin gets loaded, as
> > we want to catch events for the mails which are getting archived or Moved
> > using Email-Rules.
>

>> I have tried by adding event handler to all the folders on addin startup,
> > but it didn't work.
>

>> Is there any way to trap this event at Explorer level?
>

>> Here is the code :
> > IEnumerator enumrator =
> > _outlookApplication.Session.Folders.GetEnumerator();
> > while (enumrator.MoveNext())
> > {
> > Outlook.Folder folder = (Outlook.Folder)enumrator.Current;
> > if (folder != null)
> > {
> > AddEventHandlers(folder);
> > }
> > }
>

>> where AddEventHandlers recursively adding event hadler to each folder.
>

>> Thanks,
> > Ashutosh
>

>
>
>> " - " <kenslovak@mvps.org> wrote in message
> > news:%23pLmd%238KKHA.4136@TK2MSFTNGP04.phx.gbl...
> >> That would partially depend on what version of Outlook. For Outlook 2003
> >> and earlier you only would have the Items.ItemAdd() and ItemRemove()
> >> events on the destination and source folders to rely on. In Outlook 2007
> >> you have the Folder.BeforeItemMove() event you could also try.
> >
>>> > >>

> >>

> >
>>
>>
>>
>>
>>
>>> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in
> >> message news:eiuZfRyKKHA.4432@TK2MSFTNGP02.phx.gbl...
> >>> Hi All,
> >>
>>>> Is there any way to Catch Message Move event through outlook addin,
> >>> when message/s are moved by using Email-rules or to Archive folders?
> >>
>>>> I am able to do this on manual message move by catching ItemRemove on
> >>> selected folder.
> >>> But while running a rule I am not getting Message Move/Remove event.
> >>
>>>> Code :
> >>> outlookExplorer.CurrentFolder.Items.ItemRemove += new
> >>> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);
> >>
>>>
>>>> Thanks in advance,
> >>> Ashutosh
> >>
>>>
>>>
>>>

>

>>


>
 
A

Ashutosh Jogdande

Hi Ken,

It started working after adding event handler on cached Folder.Items, Now

events are getting fired on message Move. :)

Only concern remaining is, how do I get Entry IDs of moved messages (old

entry id before message move)?

As I can't go for Folder.BeforeItemMove() which is available in Outlook

2007.

Thanks,

Ashutosh.

"Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message

news:OGAD1PTLKHA.4316@TK2MSFTNGP04.phx.gbl...
> Hi Ken,

> Thanks for detailed reply,

> I did the same, only thing I am missing is maintaining a Custom Class,
> instead of that I have used Global List of Outlook.MAPIFolder.

> And Recursion code is inside AddEventHandlers() Method.

> But it's not working :(

> Her is the code missing in my last post:

> Global variable List<Outlook.MAPIFolder> folders;

> void AddEventHandlers(Outlook.Folder folder)
> {
> folders.Add(folder);
> logger.Debug("Adding ItemRemove eventhandler to " + folder.Name);
> folder.Items.ItemRemove += new
> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);

> IEnumerator enumrator = folder. Folders.GetEnumerator();
> while (enumrator.MoveNext())
> {
> Outlook.Folder tempFolder = (Outlook.Folder)enumrator.Current;
> if (tempFolder != null)
> {
> AddEventHandlers(tempFolder);
> }
> }
> }

> " - " <kenslovak@mvps.org> wrote in message
> news:u4TfYs$KKHA.4004@TK2MSFTNGP05.phx.gbl...
> > As you can see in the Object Browser there isn't an Explorer level event
> > you can use.
>

>> When I need to handle multiple folders, Explorers, Items collections,
> > Inspectors, etc. I set up a class to handle what I need, including all
> > events I want to handle. Then I maintain a set of those classes in a
> > collection/list/whatever to keep them alive.
>

>> For ItemRemove() and/or ItemAdd() I would do a recursive search of all
> > folders loaded that I was interested in and grab the Items collection for
> > each one, setting the Items collection object in my class to that Items
> > collection and putting it in my list. Then the events would fire
> > automatically. On shutdown I'd just unwind the list collection and null
> > out everything.
>

>> The code you show is non-recursive, it would only return top level
> > folders of the NameSpace object, which would be at the Outlook Today
> > level (top of store). If you have only one PST or mailbox loaded you'd
> > get exactly 1 handler installed and it would likely be useless. I'd
> > recursively call each Session.Folders.Item() object and dig down into
> > those also to get all the folders and their Items collections.
>

>> > >

> >

>

>
>
>
>
>
>> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message
> > news:ujM97W%23KKHA.6016@TK2MSFTNGP05.phx.gbl...
> >> Hi Ken,
> >
>>> Thanks for quick reply.
> >
>>> By adding ItemRemove event handler on outlookExplorer.CurrentFolder I am
> >> able to catch the event.
> >
>>> But How to add event handler for all folders when addin gets loaded, as
> >> we want to catch events for the mails which are getting archived or
> >> Moved using Email-Rules.
> >
>>> I have tried by adding event handler to all the folders on addin
> >> startup, but it didn't work.
> >
>>> Is there any way to trap this event at Explorer level?
> >
>>> Here is the code :
> >> IEnumerator enumrator =
> >> _outlookApplication.Session.Folders.GetEnumerator();
> >> while (enumrator.MoveNext())
> >> {
> >> Outlook.Folder folder = (Outlook.Folder)enumrator.Current;
> >> if (folder != null)
> >> {
> >> AddEventHandlers(folder);
> >> }
> >> }
> >
>>> where AddEventHandlers recursively adding event hadler to each folder.
> >
>>> Thanks,
> >> Ashutosh

> >


>
 
K

Ken Slovak - [MVP - Outlook]

There is no way to get the EntryID of the items since ItemRemove() fires

after the item was removed and doesn't give you a handle to the removed

item. You'd have to maintain a list of items in each monitored folder with

their EntryID's and compare with the current Items collection to see what

was missing.

In addition, when an item is moved within a store the EntryID may change and

the old one would no longer be valid. That happens for example in a Exchange

mailbox store where it doesn't happen with a PST file store. Whether the

EntryID changes is entirely store provider dependent.

"Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message

news:eOOVAqULKHA.1380@TK2MSFTNGP02.phx.gbl...
> Hi Ken,

> It started working after adding event handler on cached Folder.Items, Now
> events are getting fired on message Move. :)

> Only concern remaining is, how do I get Entry IDs of moved messages (old
> entry id before message move)?

> As I can't go for Folder.BeforeItemMove() which is available in Outlook
> 2007.

> Thanks,
> Ashutosh.
 
A

Ashutosh Jogdande

Hi Dmitry,

Can we trap Message Move event from one store to other store, using

redemption? (e.g. when messages are being archived).

Thanks,

Ashutosh.

"Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message

news:e7%23Z1STLKHA.4004@TK2MSFTNGP05.phx.gbl...
> Thanks Dmitry,

> Unfortunately we are not using redemption in this version :( .
> We would possibly use in our next version...

> Thanks,
> Ashutosh

> "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
> news:%23gteAhFLKHA.1376@TK2MSFTNGP02.phx.gbl...
> > <plug
>> You can do that using Redemption: it exposes RDOStore.OnMessageCreated /
> > OnMessageDeleted / etc events on the store level
> > See http://www.dimastr.com/redemption/rdo/rdostore.htm
> > <plug
>
>> > > Dmitry Streblechenko (MVP)
> >

> >

> >

> > -
> > "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message
> > news:ujM97W%23KKHA.6016@TK2MSFTNGP05.phx.gbl...
> >> Hi Ken,
> >
>>> Thanks for quick reply.
> >
>>> By adding ItemRemove event handler on outlookExplorer.CurrentFolder I am
> >> able to catch the event.
> >
>>> But How to add event handler for all folders when addin gets loaded, as
> >> we want to catch events for the mails which are getting archived or
> >> Moved using Email-Rules.
> >
>>> I have tried by adding event handler to all the folders on addin
> >> startup, but it didn't work.
> >
>>> Is there any way to trap this event at Explorer level?
> >
>>> Here is the code :
> >> IEnumerator enumrator =
> >> _outlookApplication.Session.Folders.GetEnumerator();
> >> while (enumrator.MoveNext())
> >> {
> >> Outlook.Folder folder = (Outlook.Folder)enumrator.Current;
> >> if (folder != null)
> >> {
> >> AddEventHandlers(folder);
> >> }
> >> }
> >
>>> where AddEventHandlers recursively adding event hadler to each folder.
> >
>>> Thanks,
> >> Ashutosh
> >
>>
>>
>>> " - " <kenslovak@mvps.org> wrote in message
> >> news:%23pLmd%238KKHA.4136@TK2MSFTNGP04.phx.gbl...
> >>> That would partially depend on what version of Outlook. For Outlook
> >>> 2003 and earlier you only would have the Items.ItemAdd() and
> >>> ItemRemove() events on the destination and source folders to rely on.
> >>> In Outlook 2007 you have the Folder.BeforeItemMove() event you could
> >>> also try.
> >>
>>>> > >>>

> >>>

> >>
>>>
>>>
>>>
>>>
>>>
>>>> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in
> >>> message news:eiuZfRyKKHA.4432@TK2MSFTNGP02.phx.gbl...
> >>>> Hi All,
> >>>
>>>>> Is there any way to Catch Message Move event through outlook addin,
> >>>> when message/s are moved by using Email-rules or to Archive folders?
> >>>
>>>>> I am able to do this on manual message move by catching ItemRemove on
> >>>> selected folder.
> >>>> But while running a rule I am not getting Message Move/Remove event.
> >>>
>>>>> Code :
> >>>> outlookExplorer.CurrentFolder.Items.ItemRemove += new
> >>>> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);
> >>>
>>>>
>>>>> Thanks in advance,
> >>>> Ashutosh
> >>>
>>>>
>>>>
>>>
>>
>>>

>

>>


>
 
D

Dmitry Streblechenko

Messages can only be truly moved within the same store. If you move messages

across different stores, messages are created in the target store and

deleted in the source store.

Dmitry Streblechenko (MVP)

-

"Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message

news:ONfGHoHOKHA.3588@TK2MSFTNGP05.phx.gbl...
> Hi Dmitry,

> Can we trap Message Move event from one store to other store, using
> redemption? (e.g. when messages are being archived).

> Thanks,
> Ashutosh.

> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in message
> news:e7%23Z1STLKHA.4004@TK2MSFTNGP05.phx.gbl...
> > Thanks Dmitry,
>

>> Unfortunately we are not using redemption in this version :( .
> > We would possibly use in our next version...
>

>
>> Thanks,
> > Ashutosh
>

>> "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
> > news:%23gteAhFLKHA.1376@TK2MSFTNGP02.phx.gbl...
> >> <plug
>>> You can do that using Redemption: it exposes RDOStore.OnMessageCreated /
> >> OnMessageDeleted / etc events on the store level
> >> See http://www.dimastr.com/redemption/rdo/rdostore.htm
> >> <plug
>>
>>> > >> Dmitry Streblechenko (MVP)
> >>

> >>

> >>

> >> -
> >> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in
> >> message news:ujM97W%23KKHA.6016@TK2MSFTNGP05.phx.gbl...
> >>> Hi Ken,
> >>
>>>> Thanks for quick reply.
> >>
>>>> By adding ItemRemove event handler on outlookExplorer.CurrentFolder I
> >>> am able to catch the event.
> >>
>>>> But How to add event handler for all folders when addin gets loaded, as
> >>> we want to catch events for the mails which are getting archived or
> >>> Moved using Email-Rules.
> >>
>>>> I have tried by adding event handler to all the folders on addin
> >>> startup, but it didn't work.
> >>
>>>> Is there any way to trap this event at Explorer level?
> >>
>>>> Here is the code :
> >>> IEnumerator enumrator =
> >>> _outlookApplication.Session.Folders.GetEnumerator();
> >>> while (enumrator.MoveNext())
> >>> {
> >>> Outlook.Folder folder = (Outlook.Folder)enumrator.Current;
> >>> if (folder != null)
> >>> {
> >>> AddEventHandlers(folder);
> >>> }
> >>> }
> >>
>>>> where AddEventHandlers recursively adding event hadler to each folder.
> >>
>>>> Thanks,
> >>> Ashutosh
> >>
>>>
>>>
>>>> " - " <kenslovak@mvps.org> wrote in message
> >>> news:%23pLmd%238KKHA.4136@TK2MSFTNGP04.phx.gbl...
> >>>> That would partially depend on what version of Outlook. For Outlook
> >>>> 2003 and earlier you only would have the Items.ItemAdd() and
> >>>> ItemRemove() events on the destination and source folders to rely on.
> >>>> In Outlook 2007 you have the Folder.BeforeItemMove() event you could
> >>>> also try.
> >>>
>>>>> > >>>>

> >>>>

> >>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> "Ashutosh Jogdande" <ashutosh_jogdande@persistent.co.in> wrote in
> >>>> message news:eiuZfRyKKHA.4432@TK2MSFTNGP02.phx.gbl...
> >>>>> Hi All,
> >>>>
>>>>>> Is there any way to Catch Message Move event through outlook
> >>>>> addin, when message/s are moved by using Email-rules or to Archive
> >>>>> folders?
> >>>>
>>>>>> I am able to do this on manual message move by catching ItemRemove on
> >>>>> selected folder.
> >>>>> But while running a rule I am not getting Message Move/Remove event.
> >>>>
>>>>>> Code :
> >>>>> outlookExplorer.CurrentFolder.Items.ItemRemove += new
> >>>>> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(Items_ItemRemove);
> >>>>
>>>>>
>>>>>> Thanks in advance,
> >>>>> Ashutosh
> >>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>>>

>

>>


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Catch events from pre-existing buttons in Outlook 2007 Outlook VBA and Custom Forms 7
A how to catch folder in folder remove Outlook VBA and Custom Forms 2
N Save Selected Email Message as .msg File Outlook VBA and Custom Forms 9
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
Cathy Rhone The properties of the message have been changed Using Outlook 1
S Outlook 2016 A Shortcut to recall and delete and sent message. Using Outlook 1
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
S Unable to extract text from an Outlook email message Using Outlook 2
R Outlook 2016 Message-ID oddity/inconsistency? Using Outlook 7
J Implement Keywords based on body message Outlook VBA and Custom Forms 0
C must select message to trigger safe list Using Outlook 3
witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
D.Moore VB script to Digitaly Sign newly created outlook message Outlook VBA and Custom Forms 2
O VBA Outlook Message Attachment - Array Index Out of Bounds Outlook VBA and Custom Forms 0
W September 2020 - No Default Email Client message after Office Update Using Outlook 1
A Flag Message for Follow Up after sending Outlook VBA and Custom Forms 1
S Outlook (2016 32bit; Gmail IMAP) - Save sent message to Outllook Folder Outlook VBA and Custom Forms 0
C Why won't Title display in message list? Using Outlook 1
icacream content in this message could not be downloaded.... Using Outlook 2
J Outlook 2016 After a search in all mailboxes, where is each message that was found? Using Outlook 6
R Warn before sending message Outlook VBA and Custom Forms 4
T Column to display which email alias a message was sent to Outlook VBA and Custom Forms 6
V Change start time based on message duration Outlook VBA and Custom Forms 2
J Message search and edit, another way? Outlook VBA and Custom Forms 4
N VBA to delete duplicates by message-id on common pst for 2 or more emails Outlook VBA and Custom Forms 0
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
T Missing text in e-mail message after "(Please keep confidential)" Using Outlook 3
C Custom Form (seperate layout pages and message reading pane) Outlook VBA and Custom Forms 0
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
M Message list font changed after update Using Outlook 2
BretAB Is it possible to add a lookup field to a Message form? Outlook VBA and Custom Forms 4
D Unopened message in inbox deleted and not in deleted items Using Outlook 3
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh Cannot get Macro to SAVE more than one message attachment??? Outlook VBA and Custom Forms 5
W Message class changes of a custom form changes to the default form Using Outlook 2
evdbogaard Reply with only last message cited Using Outlook 1
T O365 and Office Message Encryption Exchange Server Administration 2
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
D Outlook Message Window Changes Size and Position Using Outlook 1
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
R Retain Original Message When Forwarding With Macro Outlook VBA and Custom Forms 3
R Call a Public Sub when a Flag is clicked on in the Message Preview pane Outlook VBA and Custom Forms 1
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
P Message List Font Changed Using Outlook 6
I Automating message move between folders Outlook VBA and Custom Forms 0
U Outbox Message Stuck after reading some MailItem Properties with VBA Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Is there a way to add something that is in the "Format Text" tab to the "basic Text" on the message tab Using Outlook 1
R VBA macro - new message Outlook VBA and Custom Forms 3

Similar threads

Top