Reputation: 231
When right clicking on a calendar and running a ribbon action is it possible to get the selected calendar date the same way you would get the current mailItem or appointmentItem?
Ribbon XML:
<contextMenu idMso="ContextMenuCalendarView">
<menu id="CallenderMenu" label="Actions">
<button id="NewDiaryEvent" label="Create new" onAction="CreateCallenderItem_click" />
</menu>
</contextMenu>
C#:
public void CreateCallenderItem_click(IRibbonControl control)
{
// Get selected calendar date
}
Upvotes: 3
Views: 1686
Reputation: 1072
Dmitry is correct but here is an example of the code I have used to get the start and finish date of the area you have selected:
public void CreateCallenderItem_click(IRibbonControl control)
{
// Get selected calendar date
Outlook.Application application = new Outlook.Application();
Outlook.Explorer explorer = application.ActiveExplorer();
Outlook.Folder folder = explorer.CurrentFolder as Outlook.Folder;
Outlook.View view = explorer.CurrentView as Outlook.View;
if (view.ViewType == Outlook.OlViewType.olCalendarView)
{
Outlook.CalendarView calView = view as Outlook.CalendarView;
DateTime calDateStart = calView.SelectedStartTime;
DateTime calDateEnd = calView.SelectedEndTime;
// Do stuff with dates.
}
}
I hope this helps you some more.
Upvotes: 4
Reputation: 66225
Read Application.ActiveExplorer.CuurentFolder.CurrentView property, check if it is CalendarView, then read the CalendarView.SelectedStartTime property.
Upvotes: 2