A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to catch Message Move Event.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 1st 09, 06:50 PM posted to microsoft.public.outlook.program_addins
Ashutosh Jogdande
external usenet poster
 
Posts: 10
Default How to catch Message Move Event.

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_ItemR emoveEventHandler(Items_ItemRemove);


Thanks in advance,
Ashutosh



Ads
  #2  
Old September 2nd 09, 03:16 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to catch Message Move Event.

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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in message
...
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_ItemR emoveEventHandler(Items_ItemRemove);


Thanks in advance,
Ashutosh




  #3  
Old September 2nd 09, 05:54 PM posted to microsoft.public.outlook.program_addins
Ashutosh Jogdande
external usenet poster
 
Posts: 10
Default How to catch Message Move Event.

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



"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in message
...
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_ItemR emoveEventHandler(Items_ItemRemove);


Thanks in advance,
Ashutosh






  #4  
Old September 2nd 09, 08:27 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to catch Message Move Event.

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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in message
...
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


  #5  
Old September 3rd 09, 07:32 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to catch Message Move Event.

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)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Ashutosh Jogdande" wrote in message
...
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



"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in message
...
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_ItemR emoveEventHandler(Items_ItemRemove);


Thanks in advance,
Ashutosh








  #6  
Old September 4th 09, 09:47 AM posted to microsoft.public.outlook.program_addins
Ashutosh Jogdande
external usenet poster
 
Posts: 10
Default How to catch Message Move Event.

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 ListOutlook.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_ItemR emoveEventHandler(Items_ItemRemove);

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



"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in message
...
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




  #7  
Old September 4th 09, 09:52 AM posted to microsoft.public.outlook.program_addins
Ashutosh Jogdande
external usenet poster
 
Posts: 10
Default How to catch Message Move Event.

Thanks Dmitry,

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


Thanks,
Ashutosh

"Dmitry Streblechenko" wrote in message
...
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)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Ashutosh Jogdande" wrote in message
...
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



"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in
message ...
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_ItemR emoveEventHandler(Items_ItemRemove);


Thanks in advance,
Ashutosh










  #8  
Old September 4th 09, 12:28 PM posted to microsoft.public.outlook.program_addins
Ashutosh Jogdande
external usenet poster
 
Posts: 10
Default How to catch Message Move Event.

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" wrote in message
...
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 ListOutlook.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_ItemR emoveEventHandler(Items_ItemRemove);

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



"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in message
...
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






  #9  
Old September 4th 09, 03:18 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to catch Message Move Event.

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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in message
...
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.


  #10  
Old September 18th 09, 06:06 PM posted to microsoft.public.outlook.program_addins
Ashutosh Jogdande
external usenet poster
 
Posts: 10
Default How to catch Message Move Event.

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" wrote in message
...
Thanks Dmitry,

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


Thanks,
Ashutosh

"Dmitry Streblechenko" wrote in message
...
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)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Ashutosh Jogdande" wrote in message
...
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



"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashutosh Jogdande" wrote in
message ...
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_ItemR emoveEventHandler(Items_ItemRemove);


Thanks in advance,
Ashutosh












 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to catch javascript event in webBrowser? BatKing Outlook - Using Forms 3 November 1st 08 06:22 PM
How to catch the AdvancedSearchComplete event Pavel Rosoi Outlook - Using Forms 4 June 9th 08 09:58 PM
Catch the “Find Now” corresponding event Pavel Rosoi Add-ins for Outlook 0 June 2nd 08 05:30 PM
Can I catch the event when the End Time comes on Appointment? soworl Outlook - Calandaring 5 January 18th 08 07:46 PM
how to catch delete event(appointments) in outlook2003 us c# abdullah baig Outlook - Using Forms 0 January 15th 08 09:37 AM


All times are GMT +1. The time now is 05:53 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2025 Outlook Banter.
The comments are property of their posters.