I have a COM add in using VSTO 2005 for outlook 2003. My code adds a Forward
event handler using the explorer selection change event.
void _explr_SelectionChange()
{
for (int i = 1; i <= _explr.Selection.Count; i++)
{
object selectedItem = _explr.Selection[i];
if (selectedItem is MailItem)
{
MailItem _item = (MailItem)selectedItem;
((ItemEvents_10_Event)_item).Forward += _item_Forward;
}
}
}
The event does not fire the first time I forward an item. It fires normally
after the first time.
There is no exception being raised. I should add that we add a tool bart to
to the outlook item. It seems like the constructor for the tool bar
interferes with the Forward event registration.
I have no idea what your toolbar construction code looks like but your
forward code would correctly handle only 1 selected item, and the
declarations for the event handlers are local objects that will go out of
scope the second the SelectionChange event procedure ends.
You should be using a list or collection of some kind to add your selected
items and the event handlers for them to keep the item objects and their
event handlers in scope.
"Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
>I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
>Forward
> event handler using the explorer selection change event.
> void _explr_SelectionChange()
> {
> for (int i = 1; i <= _explr.Selection.Count; i++)
> {
> object selectedItem = _explr.Selection[i];
> if (selectedItem is MailItem)
> {
> MailItem _item = (MailItem)selectedItem;
> ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> }
> }
> }
>
> The event does not fire the first time I forward an item. It fires
> normally
> after the first time.
>
> There is no exception being raised. I should add that we add a tool bart
> to
> to the outlook item. It seems like the constructor for the tool bar
> interferes with the Forward event registration.
You were right on! When the toolbar construtor was call the item wen out of
scope.
"Ken Slovak - [MVP - Outlook]" wrote:
> I have no idea what your toolbar construction code looks like but your
> forward code would correctly handle only 1 selected item, and the
> declarations for the event handlers are local objects that will go out of
> scope the second the SelectionChange event procedure ends.
>
> You should be using a list or collection of some kind to add your selected
> items and the event handlers for them to keep the item objects and their
> event handlers in scope.
>
> --
> 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
>
>
> "Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
> news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
> >I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
> >Forward
> > event handler using the explorer selection change event.
> > void _explr_SelectionChange()
> > {
> > for (int i = 1; i <= _explr.Selection.Count; i++)
> > {
> > object selectedItem = _explr.Selection[i];
> > if (selectedItem is MailItem)
> > {
> > MailItem _item = (MailItem)selectedItem;
> > ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> > }
> > }
> > }
> >
> > The event does not fire the first time I forward an item. It fires
> > normally
> > after the first time.
> >
> > There is no exception being raised. I should add that we add a tool bart
> > to
> > to the outlook item. It seems like the constructor for the tool bar
> > interferes with the Forward event registration.
>
>
I have no idea what your toolbar construction code looks like but your
forward code would correctly handle only 1 selected item, and the
declarations for the event handlers are local objects that will go out of
scope the second the SelectionChange event procedure ends.
You should be using a list or collection of some kind to add your selected
items and the event handlers for them to keep the item objects and their
event handlers in scope.
"Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
>I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
>Forward
> event handler using the explorer selection change event.
> void _explr_SelectionChange()
> {
> for (int i = 1; i <= _explr.Selection.Count; i++)
> {
> object selectedItem = _explr.Selection[i];
> if (selectedItem is MailItem)
> {
> MailItem _item = (MailItem)selectedItem;
> ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> }
> }
> }
>
> The event does not fire the first time I forward an item. It fires
> normally
> after the first time.
>
> There is no exception being raised. I should add that we add a tool bart
> to
> to the outlook item. It seems like the constructor for the tool bar
> interferes with the Forward event registration.
You were right on! When the toolbar construtor was call the item wen out of
scope.
"Ken Slovak - [MVP - Outlook]" wrote:
> I have no idea what your toolbar construction code looks like but your
> forward code would correctly handle only 1 selected item, and the
> declarations for the event handlers are local objects that will go out of
> scope the second the SelectionChange event procedure ends.
>
> You should be using a list or collection of some kind to add your selected
> items and the event handlers for them to keep the item objects and their
> event handlers in scope.
>
> --
> 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
>
>
> "Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
> news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
> >I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
> >Forward
> > event handler using the explorer selection change event.
> > void _explr_SelectionChange()
> > {
> > for (int i = 1; i <= _explr.Selection.Count; i++)
> > {
> > object selectedItem = _explr.Selection[i];
> > if (selectedItem is MailItem)
> > {
> > MailItem _item = (MailItem)selectedItem;
> > ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> > }
> > }
> > }
> >
> > The event does not fire the first time I forward an item. It fires
> > normally
> > after the first time.
> >
> > There is no exception being raised. I should add that we add a tool bart
> > to
> > to the outlook item. It seems like the constructor for the tool bar
> > interferes with the Forward event registration.
>
>
I have no idea what your toolbar construction code looks like but your
forward code would correctly handle only 1 selected item, and the
declarations for the event handlers are local objects that will go out of
scope the second the SelectionChange event procedure ends.
You should be using a list or collection of some kind to add your selected
items and the event handlers for them to keep the item objects and their
event handlers in scope.
"Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
>I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
>Forward
> event handler using the explorer selection change event.
> void _explr_SelectionChange()
> {
> for (int i = 1; i <= _explr.Selection.Count; i++)
> {
> object selectedItem = _explr.Selection[i];
> if (selectedItem is MailItem)
> {
> MailItem _item = (MailItem)selectedItem;
> ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> }
> }
> }
>
> The event does not fire the first time I forward an item. It fires
> normally
> after the first time.
>
> There is no exception being raised. I should add that we add a tool bart
> to
> to the outlook item. It seems like the constructor for the tool bar
> interferes with the Forward event registration.
You were right on! When the toolbar construtor was call the item wen out of
scope.
"Ken Slovak - [MVP - Outlook]" wrote:
> I have no idea what your toolbar construction code looks like but your
> forward code would correctly handle only 1 selected item, and the
> declarations for the event handlers are local objects that will go out of
> scope the second the SelectionChange event procedure ends.
>
> You should be using a list or collection of some kind to add your selected
> items and the event handlers for them to keep the item objects and their
> event handlers in scope.
>
> --
> 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
>
>
> "Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
> news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
> >I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
> >Forward
> > event handler using the explorer selection change event.
> > void _explr_SelectionChange()
> > {
> > for (int i = 1; i <= _explr.Selection.Count; i++)
> > {
> > object selectedItem = _explr.Selection[i];
> > if (selectedItem is MailItem)
> > {
> > MailItem _item = (MailItem)selectedItem;
> > ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> > }
> > }
> > }
> >
> > The event does not fire the first time I forward an item. It fires
> > normally
> > after the first time.
> >
> > There is no exception being raised. I should add that we add a tool bart
> > to
> > to the outlook item. It seems like the constructor for the tool bar
> > interferes with the Forward event registration.
>
>
I have no idea what your toolbar construction code looks like but your
forward code would correctly handle only 1 selected item, and the
declarations for the event handlers are local objects that will go out of
scope the second the SelectionChange event procedure ends.
You should be using a list or collection of some kind to add your selected
items and the event handlers for them to keep the item objects and their
event handlers in scope.
"Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
>I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
>Forward
> event handler using the explorer selection change event.
> void _explr_SelectionChange()
> {
> for (int i = 1; i <= _explr.Selection.Count; i++)
> {
> object selectedItem = _explr.Selection[i];
> if (selectedItem is MailItem)
> {
> MailItem _item = (MailItem)selectedItem;
> ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> }
> }
> }
>
> The event does not fire the first time I forward an item. It fires
> normally
> after the first time.
>
> There is no exception being raised. I should add that we add a tool bart
> to
> to the outlook item. It seems like the constructor for the tool bar
> interferes with the Forward event registration.
You were right on! When the toolbar construtor was call the item wen out of
scope.
"Ken Slovak - [MVP - Outlook]" wrote:
> I have no idea what your toolbar construction code looks like but your
> forward code would correctly handle only 1 selected item, and the
> declarations for the event handlers are local objects that will go out of
> scope the second the SelectionChange event procedure ends.
>
> You should be using a list or collection of some kind to add your selected
> items and the event handlers for them to keep the item objects and their
> event handlers in scope.
>
> --
> 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
>
>
> "Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
> news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
> >I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
> >Forward
> > event handler using the explorer selection change event.
> > void _explr_SelectionChange()
> > {
> > for (int i = 1; i <= _explr.Selection.Count; i++)
> > {
> > object selectedItem = _explr.Selection[i];
> > if (selectedItem is MailItem)
> > {
> > MailItem _item = (MailItem)selectedItem;
> > ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> > }
> > }
> > }
> >
> > The event does not fire the first time I forward an item. It fires
> > normally
> > after the first time.
> >
> > There is no exception being raised. I should add that we add a tool bart
> > to
> > to the outlook item. It seems like the constructor for the tool bar
> > interferes with the Forward event registration.
>
>
I have no idea what your toolbar construction code looks like but your
forward code would correctly handle only 1 selected item, and the
declarations for the event handlers are local objects that will go out of
scope the second the SelectionChange event procedure ends.
You should be using a list or collection of some kind to add your selected
items and the event handlers for them to keep the item objects and their
event handlers in scope.
"Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
>I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
>Forward
> event handler using the explorer selection change event.
> void _explr_SelectionChange()
> {
> for (int i = 1; i <= _explr.Selection.Count; i++)
> {
> object selectedItem = _explr.Selection[i];
> if (selectedItem is MailItem)
> {
> MailItem _item = (MailItem)selectedItem;
> ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> }
> }
> }
>
> The event does not fire the first time I forward an item. It fires
> normally
> after the first time.
>
> There is no exception being raised. I should add that we add a tool bart
> to
> to the outlook item. It seems like the constructor for the tool bar
> interferes with the Forward event registration.
You were right on! When the toolbar construtor was call the item wen out of
scope.
"Ken Slovak - [MVP - Outlook]" wrote:
> I have no idea what your toolbar construction code looks like but your
> forward code would correctly handle only 1 selected item, and the
> declarations for the event handlers are local objects that will go out of
> scope the second the SelectionChange event procedure ends.
>
> You should be using a list or collection of some kind to add your selected
> items and the event handlers for them to keep the item objects and their
> event handlers in scope.
>
> --
> 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
>
>
> "Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
> news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
> >I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
> >Forward
> > event handler using the explorer selection change event.
> > void _explr_SelectionChange()
> > {
> > for (int i = 1; i <= _explr.Selection.Count; i++)
> > {
> > object selectedItem = _explr.Selection[i];
> > if (selectedItem is MailItem)
> > {
> > MailItem _item = (MailItem)selectedItem;
> > ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> > }
> > }
> > }
> >
> > The event does not fire the first time I forward an item. It fires
> > normally
> > after the first time.
> >
> > There is no exception being raised. I should add that we add a tool bart
> > to
> > to the outlook item. It seems like the constructor for the tool bar
> > interferes with the Forward event registration.
>
>
I have no idea what your toolbar construction code looks like but your
forward code would correctly handle only 1 selected item, and the
declarations for the event handlers are local objects that will go out of
scope the second the SelectionChange event procedure ends.
You should be using a list or collection of some kind to add your selected
items and the event handlers for them to keep the item objects and their
event handlers in scope.
"Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
>I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
>Forward
> event handler using the explorer selection change event.
> void _explr_SelectionChange()
> {
> for (int i = 1; i <= _explr.Selection.Count; i++)
> {
> object selectedItem = _explr.Selection[i];
> if (selectedItem is MailItem)
> {
> MailItem _item = (MailItem)selectedItem;
> ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> }
> }
> }
>
> The event does not fire the first time I forward an item. It fires
> normally
> after the first time.
>
> There is no exception being raised. I should add that we add a tool bart
> to
> to the outlook item. It seems like the constructor for the tool bar
> interferes with the Forward event registration.
You were right on! When the toolbar construtor was call the item wen out of
scope.
"Ken Slovak - [MVP - Outlook]" wrote:
> I have no idea what your toolbar construction code looks like but your
> forward code would correctly handle only 1 selected item, and the
> declarations for the event handlers are local objects that will go out of
> scope the second the SelectionChange event procedure ends.
>
> You should be using a list or collection of some kind to add your selected
> items and the event handlers for them to keep the item objects and their
> event handlers in scope.
>
> --
> 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
>
>
> "Ron Coffee" <Ron Coffee@discussions.microsoft.com> wrote in message
> news:5A03DAD9-69B5-4FA1-9050-D28183299FA6@microsoft.com...
> >I have a COM add in using VSTO 2005 for outlook 2003. My code adds a
> >Forward
> > event handler using the explorer selection change event.
> > void _explr_SelectionChange()
> > {
> > for (int i = 1; i <= _explr.Selection.Count; i++)
> > {
> > object selectedItem = _explr.Selection[i];
> > if (selectedItem is MailItem)
> > {
> > MailItem _item = (MailItem)selectedItem;
> > ((ItemEvents_10_Event)_item).Forward += _item_Forward;
> > }
> > }
> > }
> >
> > The event does not fire the first time I forward an item. It fires
> > normally
> > after the first time.
> >
> > There is no exception being raised. I should add that we add a tool bart
> > to
> > to the outlook item. It seems like the constructor for the tool bar
> > interferes with the Forward event registration.
>
>