TheNewCOMAddin Dev
Guest
|
Hi,
I have the following code for a Outlook ADX Addin : I have setup an Outlook Items Events class and the AddinModule.css file has the following snippet.
....
private void ConnectToSelectedItem(Outlook.Selection selection)
{
DebugWriteLine("Inside : ConnectToSelectedItem");
if (selection != null)
{
if (selection.Count == 1)
{
try
{
// If its anything other that Mail. We don't support at this point.
if (selection[1] is Outlook.MailItem)
{
Outlook.MailItem item = (Outlook.MailItem)selection[1];
if (replyAllChecker.IsConnected)
{
replyAllChecker.RemoveConnection();
DebugWriteLine("Disconnected from the previously connected item.");
}
replyAllChecker.ConnectTo(item, true);
DebugWriteLine("Connected to this Outlook item.");
}
else
{
// If its anything other that Mail. We don't support at this point.
DebugWriteLine("Do not connect to this Outlook item.");
}
}
catch (Exception e) {
DebugWriteLine("CCCC");
DebugWriteLine(e.ToString());
}
}
}
}
private void adxOutlookAppEvents_ExplorerActivate(object sender, object explorer)
{
DebugWriteLine("The ExplorerActivate event has occurred.");
Outlook.Explorer theExplorer = explorer as Outlook.Explorer;
if (theExplorer != null)
{
Outlook.Selection selection = null;
try
{
if (theExplorer.Selection != null)
{
selection = theExplorer.Selection;
if (selection != null)
{
DebugWriteLine("Trying ConnectToSelectedItem.");
ConnectToSelectedItem(selection);
//if (selection != null) Marshal.ReleaseComObject(selection);
}
}
}
catch(Exception e) {
DebugWriteLine("FFFF");
if (selection != null) Marshal.ReleaseComObject(selection);
//if (theExplorer != null) Marshal.ReleaseComObject(theExplorer);
}
}
}
adxOutlookAppEvents_ExplorerSelectionChange(object sender, object explorer)
{
DebugWriteLine("The ExplorerSelectionChange event has occurred.");
try
{
Outlook.Explorer theExplorer = explorer as Outlook.Explorer;
if (theExplorer != null)
{
Outlook.Selection selection = null;
try
{
selection = theExplorer.Selection;
if (selection != null)
{
DebugWriteLine("Trying ConnectToSelectedItem.");
ConnectToSelectedItem(selection);
if (selection != null) Marshal.ReleaseComObject(selection);
}
}
catch {
DebugWriteLine("EEEEE");
}
}
}
catch
{
DebugWriteLine("COM Object Already Released ");
}
}
private void AddinModule_AddinStartupComplete(object sender, EventArgs e)
{
DebugWriteLine("The AddinStartupComplete event has occurred.");
DebugWriteLine("The add-in has been loaded in Outlook " + this.HostMajorVersion.ToString());
// This creates an instance of the class that handles the events of an Outlook item
replyAllChecker = new OutlookItemEventsClass1(this);
}
However, when I put breakpoint in ProcessRead : I found that
When I navigate to a email (Reading Pane on and Right) the ProcessRead gets called. now when I go to some other email and come back to the same email the ProcessRead does not get called. Any clue whats going on.
I thought the ProcessRead would get called every time the user navigates to an email. Please clarify when all is this expected to get called. |
|
Andrei Smolin
Add-in Express team
Posts: 18830
Joined: 2006-05-11
|
Hello Jatin,
First off, all events you receive are generated by Office, not by Add-in Express.
TheNewCOMAddin Dev writes:
// If its anything other that Mail. We don't support at this point.
if (selection[1] is Outlook.MailItem)
{
Outlook.MailItem item = (Outlook.MailItem)selection[1];
if (replyAllChecker.IsConnected)
{
replyAllChecker.RemoveConnection();
DebugWriteLine("Disconnected from the previously connected item.");
}
replyAllChecker.ConnectTo(item, true);
DebugWriteLine("Connected to this Outlook item.");
}
else
{
// If its anything other that Mail. We don't support at this point.
DebugWriteLine("Do not connect to this Outlook item.");
}
selection[1] creates a COM object that you need to release. You create it twice: one is passed to replyAllChecker.ConnectTo; the other is left unreleased. This may relate to the issue that you have.
also, make sure all other COM add-ins are off.
Andrei Smolin
Add-in Express Team Leader |
|