M
Marcin
Hi,
I am writing an add-in, that does few things, with emails and appointments
on the calendar. I need to read every item once it it selected by user,
since ItemLoad fires only once, and I got to get Item's few properties upon
it's selection.
Handling MailItems this way works just fine, but I encountered strange
behaviour. Switching to calendar, and selecting any existing appointment,
makes SelectionChange event be triggered multiple times, instead of just one.
Any idea why ?
My event code :
void ThisAddIn_SelectionChange()
{
try
{
if (Application.ActiveExplorer().Selection.Count > 0)
{
if (Application.ActiveExplorer().Selection[1] is
Outlook.MailItem)
{
Outlook.MailItem Item =
(Outlook.MailItem)Application.ActiveExplorer().Selection[1];
this.OutlookItem = (Outlook.MailItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.AppointmentItem)
{
Outlook.AppointmentItem Item =
(Outlook.AppointmentItem)Application.ActiveExplorer().Selection[1];
this.OutlookItem = (Outlook.AppointmentItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.MeetingItem)
{
Outlook.MeetingItem Item =
(Outlook.MeetingItem)Application.ActiveExplorer().Selection[1];
this.OutlookItem = (Outlook.MeetingItem)Item;
}
// set certain properties for the add-in, no matter what
type of Item is being dealt with
this.setProperties();
}
}
catch (Exception ex)
{
//do nothing yet
}
}
The .setProperties() does same kind of check that is :
I am writing an add-in, that does few things, with emails and appointments
on the calendar. I need to read every item once it it selected by user,
since ItemLoad fires only once, and I got to get Item's few properties upon
it's selection.
Handling MailItems this way works just fine, but I encountered strange
behaviour. Switching to calendar, and selecting any existing appointment,
makes SelectionChange event be triggered multiple times, instead of just one.
Any idea why ?
My event code :
void ThisAddIn_SelectionChange()
{
try
{
if (Application.ActiveExplorer().Selection.Count > 0)
{
if (Application.ActiveExplorer().Selection[1] is
Outlook.MailItem)
{
Outlook.MailItem Item =
(Outlook.MailItem)Application.ActiveExplorer().Selection[1];
this.OutlookItem = (Outlook.MailItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.AppointmentItem)
{
Outlook.AppointmentItem Item =
(Outlook.AppointmentItem)Application.ActiveExplorer().Selection[1];
this.OutlookItem = (Outlook.AppointmentItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.MeetingItem)
{
Outlook.MeetingItem Item =
(Outlook.MeetingItem)Application.ActiveExplorer().Selection[1];
this.OutlookItem = (Outlook.MeetingItem)Item;
}
// set certain properties for the add-in, no matter what
type of Item is being dealt with
this.setProperties();
}
}
catch (Exception ex)
{
//do nothing yet
}
}
The .setProperties() does same kind of check that is :