Alex Rakov
Posts: 31
Joined: 2006-11-16
|
Hi,
I have a problem with ItemEvents object.
I uses ItemEvents object to hook on Reply, Send events.
In the normal case everything works fine. But when someone press Reply
several times on the same mail without closing the inspector
the second event doesn't fire (or third).
When several different mails are clicked the code works fine.
Maybe you could suggest what I'm doing wrong.
Here my code for AddInModule:
private void adxOutlookEvents_InspectorActivate(object sender, object inspector, string folderName)
{
try
{
if (itemEvents.IsConnected) itemEvents.RemoveConnection();
itemEvents.ConnectTo(((Outlook.Inspector)inspector).CurrentItem, true);
}
catch
{
}
}
private void adxOutlookEvents_InspectorClose(object sender, object inspector, string folderName)
{
try
{
itemEvents.RemoveConnection();
Outlook.Explorer explorer = null;
try
{
explorer = OutlookApp.ActiveExplorer();
if (explorer != null)
{
adxOutlookEvents_ExplorerSelectionChange(this, explorer);
}
}
finally
{
if (explorer != null)
Marshal.ReleaseComObject(explorer);
}
}
catch
{
}
}
private void adxOutlookEvents_ExplorerSelectionChange(object sender, object explorer)
{
try
{
if (explorer != null)
{
Outlook.Selection selection = ((Outlook.Explorer)explorer).Selection;
try
{
if (selection != null && selection.Count > 0)
{
if (itemEvents.IsConnected) itemEvents.RemoveConnection();
itemEvents.ConnectTo(selection[1], true);
}
}
finally
{
if (selection != null)
Marshal.ReleaseComObject(selection);
}
}
}
catch
{
}
}
With best regards
Alex Rakov |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Alex.
Please test the following example:
http://www.add-in-express.com/projects/outlookitemevents.zip
P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found. |
|
Alex Rakov
Posts: 31
Joined: 2006-11-16
|
Hi Sergey,
It works only in Inspector. But I would like that this code works for Reply as well when I pressing Reply in Explorer.
With best regards
Alex Rakov |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Alex,
in this case you also need to use the ExplorerActivate event handler to connect to the selected item in Outlook explorer. |
|
Alex Rakov
Posts: 31
Joined: 2006-11-16
|
Thank you,
now it works!! |
|