Calendar Selection

Add-in Express™ Support Service
That's what is more important than anything else

Calendar Selection
Creating calendar entry with user's selected date/time 
Bruce Swan

Posts: 29
Joined: 2009-01-28
A while back I opened a thread on how to create a meeting request that contains the user's current selection from the Calendar view. You're suggestion was to create a hidden appointment and look at the start/end times. In fact, this is exactly what I do, however it always contains the current date/time for a start date/time with a 30 minute duration rather than what was selected in calendar view. I know that when you create an appointment via the menu off the Calendar view, it does use the current selection, but for whatever reason I can't reproduce this behavior in the code. Any idea why?

My code is simply:

Outlook.AppointmentItem oAppointment = (this.HostApplication as Outlook.Application).CreateItem(Outlook.OlItemType.olAppointment) as Outlook.AppointmentItem;

Shouldn't this set the start/end date/time using the current calendar selection as is done in the UI?

Posted 08 Jul, 2009 15:17:18 Top
Andrei Smolin

Add-in Express team

Posts: 14675
Joined: 2006-05-11

You need to find that button programmatically (ID=1106, CommandbarName="Standard") and call its Execute method. Then you need to handle NewInspector event, get the item being opened in the inspector (it's supplied in the corresponding parameter of the event), wait for the Open event of the item (see ProcessOpen of the Outlook Item Events class), in which you read the Start and End properties of the item and cancel this event.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Jul, 2009 11:52:34 Top