Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In C# Outlook VSTO, is there a way to change users view to the calendar view and highlight a specific day?

I want to create a button in an outlook VSTO addin that when clicked, will show the users outlook calendar week view and i want to pass in a date that will drive what week it show.

Is this possible in C# outlook vsto to programatically changes the users view?

like image 864
leora Avatar asked Dec 29 '15 18:12

leora


People also ask

What is ?: operator in C?

C operators are one of the features in C which has symbols that can be used to perform mathematical, relational, bitwise, conditional, or logical manipulations. The C programming language has a lot of built-in operators to perform various tasks as per the need of the program.

What does |= mean in C?

The bitwise OR assignment operator ( |= ) uses the binary representation of both operands, does a bitwise OR operation on them and assigns the result to the variable.

What does %d do in C?

In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.


1 Answers

Create a new button and on its on click event use the CurrentView property of the Explorer class.

Information from MSDN states regarding Views:

The View object allows you to create customizable views that allow you to better sort, group and ultimately view data of all different types. There are a variety of different view types that provide the flexibility needed to create and maintain your important data.

  • The table view type (olTableView) allows you to view data in a simple field-based table.
  • The Calendar view type (olCalendarView) allows you to view data in a calendar format.
  • The card view type (olCardView) allows you to view data in a series of cards. Each card displays the information contained by the item
    and can be sorted.
  • The icon view type (olIconView) allows you to view data as icons, similar to a Windows folder or explorer.
  • The timeline view type (olTimelineView) allows you to view data as it is received in a customizable linear time line.

You'll want to use olCalendarView which is defiened and customized using the View object's XML property. The XML property allows you to create and set a customized XML schema that defines the various features of a view

Then you can set the date you want (in case your current view is calendar view) -

Outlook.Explorer olkExplorer = Application.ActiveExplorer();
DateTime selectedDate = DateTime.Now.AddDays(5);

if (olkExplorer.CurrentView is Outlook.CalendarView)
{
    Outlook.CalendarView olkCalendarView = olkExplorer.CurrentView as Outlook.CalendarView;

    olkCalendarView.GoToDate(selectedDate);
} 

I hope it supports your question.

like image 118
DeJaVo Avatar answered Oct 12 '22 23:10

DeJaVo