PC Review


Reply
Thread Tools Rate Thread

Outlook 2003 Appointments -- drag and drop event using C#

 
 
Curtis Justus
Guest
Posts: n/a
 
      28th Jul 2008
Hi everybody,

I have created an add-in where I need to capture a drag and drop event of an
appointment in a user's calendar. I used the ItemLoad event in the 2007
libraries, but that doesn't exist in 2003.

I have attached to the Items.ItemChange event of the calendar folder
(olFolderCalendar), but that never fires. For that matter, neither does the
ItemAdd or ItemRemove events.

I have my inspectors hooked up, but they never fire because an inspector is
not created on a drag-drop of an appointment.

Would anybody have any ideas of something I can try?

Thanks for your help,
cj

 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      29th Jul 2008
If you add a new item to the calendar folder, not with drag and drop but
Actions, New Appointment does ItemAdd() fire at all? If not then it's
something in how you're creating or scoping your event handler.

Is the folder object and items collection declared at a class or other scope
level that will keep them alive once your procedure where you add the event
handler ends?

Show the code you use to create the event handlers.

--
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


"Curtis Justus" <(E-Mail Removed)> wrote in message
news:OtF$(E-Mail Removed)...
> Hi everybody,
>
> I have created an add-in where I need to capture a drag and drop event of
> an appointment in a user's calendar. I used the ItemLoad event in the
> 2007 libraries, but that doesn't exist in 2003.
>
> I have attached to the Items.ItemChange event of the calendar folder
> (olFolderCalendar), but that never fires. For that matter, neither does
> the ItemAdd or ItemRemove events.
>
> I have my inspectors hooked up, but they never fire because an inspector
> is not created on a drag-drop of an appointment.
>
> Would anybody have any ideas of something I can try?
>
> Thanks for your help,
> cj


 
Reply With Quote
 
Curtis Justus
Guest
Posts: n/a
 
      29th Jul 2008
Hello Ken,

If I hook up the ItemAdd event, it does not fire if I add anything -- even
without the drag and drop.

Here is the code I am using...

public partial class ThisAddIn
{
private Outlook.Application outApp;
private Outlook.NameSpace _nameSpace;
private Outlook.MAPIFolder _calendarFolder;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outApp = this.Application;

_nameSpace = outApp.GetNamespace("MAPI");

_calendarFolder =
_nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

_calendarFolder.Items.ItemAdd += new
ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
}

void Items_ItemAdd(object Item)
{
MessageBox.Show("Item Added");
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
_calendarFolder.Items.ItemAdd -= new
ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
outApp = null;

}
}

Thanks for your help...
cj

"Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> If you add a new item to the calendar folder, not with drag and drop but
> Actions, New Appointment does ItemAdd() fire at all? If not then it's
> something in how you're creating or scoping your event handler.
>
> Is the folder object and items collection declared at a class or other
> scope level that will keep them alive once your procedure where you add
> the event handler ends?
>
> Show the code you use to create the event handlers.
>
> --
> 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
>
>
> "Curtis Justus" <(E-Mail Removed)> wrote in message
> news:OtF$(E-Mail Removed)...
>> Hi everybody,
>>
>> I have created an add-in where I need to capture a drag and drop event of
>> an appointment in a user's calendar. I used the ItemLoad event in the
>> 2007 libraries, but that doesn't exist in 2003.
>>
>> I have attached to the Items.ItemChange event of the calendar folder
>> (olFolderCalendar), but that never fires. For that matter, neither does
>> the ItemAdd or ItemRemove events.
>>
>> I have my inspectors hooked up, but they never fire because an inspector
>> is not created on a drag-drop of an appointment.
>>
>> Would anybody have any ideas of something I can try?
>>
>> Thanks for your help,
>> cj

>


 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      29th Jul 2008
Your Items collection is going out of scope as soon as that procedure ends.
Then it gets garbage collected and your event handlers then fail to fire.

Your class level declarations section should include a declaration for an
Items collection:

private Outlook.Items _items;

Assign that to your calendar folder's items collection and add the event
handler to that Items collection and the events should start to fire.

--
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


"Curtis Justus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Ken,
>
> If I hook up the ItemAdd event, it does not fire if I add anything -- even
> without the drag and drop.
>
> Here is the code I am using...
>
> public partial class ThisAddIn
> {
> private Outlook.Application outApp;
> private Outlook.NameSpace _nameSpace;
> private Outlook.MAPIFolder _calendarFolder;
>
> private void ThisAddIn_Startup(object sender, System.EventArgs e)
> {
> outApp = this.Application;
>
> _nameSpace = outApp.GetNamespace("MAPI");
>
> _calendarFolder =
> _nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
>
> _calendarFolder.Items.ItemAdd += new
> ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
> }
>
> void Items_ItemAdd(object Item)
> {
> MessageBox.Show("Item Added");
> }
> private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
> {
> _calendarFolder.Items.ItemAdd -= new
> ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
> outApp = null;
>
> }
> }
>
> Thanks for your help...
> cj


 
Reply With Quote
 
Curtis Justus
Guest
Posts: n/a
 
      29th Jul 2008
VOILA!

Ken... you got me thinking about the scope. Since I wasn't referring to the
Items collection directly in my definition, I thought maybe something was
getting disconnected in the Interop with the com layer. I set up a class
level variable:

private Items _calendarItems;

Then, I put the following code in the startup:

_calendarItems.ItemChange += new
ItemsEvents_ItemChangeEventHandler(_calendarItems_ItemChange);

Lo and behold, the change event fires -- even on the drag and drop.

Thanks for pointing me in the right direction...
cj

"Curtis Justus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Ken,
>
> If I hook up the ItemAdd event, it does not fire if I add anything -- even
> without the drag and drop.
>
> Here is the code I am using...
>
> public partial class ThisAddIn
> {
> private Outlook.Application outApp;
> private Outlook.NameSpace _nameSpace;
> private Outlook.MAPIFolder _calendarFolder;
>
> private void ThisAddIn_Startup(object sender, System.EventArgs e)
> {
> outApp = this.Application;
>
> _nameSpace = outApp.GetNamespace("MAPI");
>
> _calendarFolder =
> _nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
>
> _calendarFolder.Items.ItemAdd += new
> ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
> }
>
> void Items_ItemAdd(object Item)
> {
> MessageBox.Show("Item Added");
> }
> private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
> {
> _calendarFolder.Items.ItemAdd -= new
> ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
> outApp = null;
>
> }
> }
>
> Thanks for your help...
> cj
>
> "Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> If you add a new item to the calendar folder, not with drag and drop but
>> Actions, New Appointment does ItemAdd() fire at all? If not then it's
>> something in how you're creating or scoping your event handler.
>>
>> Is the folder object and items collection declared at a class or other
>> scope level that will keep them alive once your procedure where you add
>> the event handler ends?
>>
>> Show the code you use to create the event handlers.
>>
>> --
>> 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
>>
>>
>> "Curtis Justus" <(E-Mail Removed)> wrote in message
>> news:OtF$(E-Mail Removed)...
>>> Hi everybody,
>>>
>>> I have created an add-in where I need to capture a drag and drop event
>>> of an appointment in a user's calendar. I used the ItemLoad event in
>>> the 2007 libraries, but that doesn't exist in 2003.
>>>
>>> I have attached to the Items.ItemChange event of the calendar folder
>>> (olFolderCalendar), but that never fires. For that matter, neither does
>>> the ItemAdd or ItemRemove events.
>>>
>>> I have my inspectors hooked up, but they never fire because an inspector
>>> is not created on a drag-drop of an appointment.
>>>
>>> Would anybody have any ideas of something I can try?
>>>
>>> Thanks for your help,
>>> cj

>>

>


 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      29th Jul 2008
You always have to be more aware of scoping and possible garbage collection
in managed code than in unmanaged code. You'd be surprised at how many
problems are solved just by thinking about and following scoping rules.

Good, I'm glad things are working now.

--
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


"Curtis Justus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> VOILA!
>
> Ken... you got me thinking about the scope. Since I wasn't referring to
> the Items collection directly in my definition, I thought maybe something
> was getting disconnected in the Interop with the com layer. I set up a
> class level variable:
>
> private Items _calendarItems;
>
> Then, I put the following code in the startup:
>
> _calendarItems.ItemChange += new
> ItemsEvents_ItemChangeEventHandler(_calendarItems_ItemChange);
>
> Lo and behold, the change event fires -- even on the drag and drop.
>
> Thanks for pointing me in the right direction...
> cj


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to drag and drop appointments JT Microsoft Outlook Calendar 2 9th Sep 2009 04:21 PM
Email Drag and Drop Event in outlook =?Utf-8?B?RWxhbmNoZXpoaWFuLlI=?= Microsoft Outlook VBA Programming 5 24th Jul 2009 12:25 PM
Outlook Folder Drag and Drop Event jsturma Microsoft Outlook VBA Programming 5 25th Sep 2006 10:33 PM
BETA Outlook 2007 - Can't drag-n-drop appointments in 'day' view =?Utf-8?B?Tm9lbCBIYXN0aW5ncw==?= Microsoft Outlook Discussion 7 18th Jul 2006 05:26 AM
Can't drag and drop appointments =?Utf-8?B?QnJ5YW4=?= Microsoft Outlook Calendar 0 20th Jan 2005 10:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:11 PM.