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

Outlook Mail Item Open Event Doesn't Work



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old October 7th 08, 04:30 PM posted to microsoft.public.outlook.program_addins
Nenad Dobrilovic
external usenet poster
 
Posts: 10
Default Outlook Mail Item Open Event Doesn't Work

I have an interesting issue with Open mail item's event.

I have a MailItem wrapper class, which exposes Opening event like this;

public class MailDocument
{
private Outlook.MailItem mailItem;

private static Dictionarystring, MailDocument documents = new
Dictionarystring, MailDocument();

public event ActionMailDocument, CancelEventArgs Opening;

public MailDocument(Outlook.MailItem item)
{
this.mailItem = item;
((Outlook.ItemEvents_10_Event)mailItem).Open += new
Outlook.ItemEvents_10_OpenEventHandler(onOpen);
documents.Add(item.EntryID, this);
}

private void onOpen(ref bool cancel)
{
CancelEventArgs args = new CancelEventArgs(cancel);
Opening(this, args);
cancel = args.Cancel;
}

public static MailDocument Get(Outlook.MailItem mailItem)
{
MailDocument mailDocument;
documents.TryGetValue(mailItem.EntryID, out mailDocument);
return mailDocument;
}
}
}

NewInspector event handler is like this:

Outlook.MailItem current = inspector.CurrentItem as
Outlook.MailItem;
MailDocument mailDocument = MailDocument.Get(current);
mailDocument.Opening += new ActionMailDocument,
CancelEventArgs(OnOpening);

Opening event is never invoked.
But, if I change these lines of code, event handler is invoked every time.

Outlook.MailItem current = inspector.CurrentItem as
Outlook.MailItem;
MailDocument mailDocument = new MailDocument(current);
mailDocument.Opening += new ActionMailDocument,
CancelEventArgs(OnOpening);

Do you have an idea why this is happening? I noticed that in the default
Microsoft example is the same. Also, if I cancel a mail item default
inspector, it does shows for a part of second, so that a display is
flickering a little bit.
--
Nenad Dobrilovic
 




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
Event fired while opening a selected mail item in Outlook. ASAR Add-ins for Outlook 5 May 19th 08 09:40 PM
event raised on selecting a mail item in ms outlook ASAR Add-ins for Outlook 1 May 19th 08 12:57 PM
New Mail Item Event Neetu Add-ins for Outlook 6 April 4th 08 02:11 PM
catch the mail item on_focus event john Outlook and VBA 1 September 28th 06 12:33 PM
Item Open event does not occurs every time sfradel Add-ins for Outlook 1 September 2nd 06 04:33 PM


All times are GMT +1. The time now is 08:00 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.