Configuring SharePoint MyCalendar Web Parts to Synchronize with Exchange E-Mail Accounts

Summary: Learn about various collaboration features in Microsoft SharePoint Server 2010, such as how to configure, use, and extend the My Calendar Web Part to synchronize with your corporate Microsoft Exchange email account.

Wrox logo

Wrox SharePoint Books

Applies to: Business Connectivity Services | Exchange Server | Open XML | SharePoint Designer 2010 | SharePoint Foundation 2010 | SharePoint Online | SharePoint Server 2010 | Visual Studio

Author: Johnny Harbieh

Editors: Wrox Tech Editors for SharePoint 2010 Articles


  • Introduction to Collaborative Features in SharePoint Server 2010

  • Calendars in SharePoint 2010

  • Adding and Configuring the My Calendar Web Part

  • Extending the My Calendar Web Part

  • About the Author

  • Additional Resources

Introduction to Collaborative Features in SharePoint Server 2010

SharePoint 2010 combines features and tools that enable people and processes to work better together. Team members who are working together on the same project can work and collaborate more efficiently. Table 1 lists some of the collaboration features in SharePoint.

Table 1. Collaboration features in SharePoint Server 2010




Use blog sites to share knowledge and provide guidance to team members and internal or external visitors.


Use discussion lists to create discussion threads and reply to team discussions.


Use wiki sites and pages to quickly add and update content.

Team Sites

Use team sites to share and contribute content.


Use a calendar list to manage corporate or team events.


Use a task list to manage project tasks.


Use workspaces to collaborate offline or online.

The next section discusses how to use calendars on collaborative SharePoint sites.

Calendars in SharePoint 2010

The list of collaboration features in the preceding section is only a subset. This section discusses how to use one of the features on that list, calendars. SharePoint Foundation 2010 provides the calendars in SharePoint 2010. Calendars are central to most collaborative and departmental team sites.

Imagine that you are involved in a project. Because the project manager must keep track of meetings and deadlines, he or she must have access to calendars, task lists, and so on. The project manager can create a SharePoint site and add a calendar. The calendar can be a team calendar that is stored in SharePoint, or a Calendar that is stored in Exchange but is displayed in SharePoint.

The following are some examples of how teams use calendars on SharePoint sites today.

Example 1: SharePoint Calendar List

Create and manage a calendar list in SharePoint. Team members can view or edit events on the calendar list, depending on their permissions. You can synchronize calendar lists in SharePoint 2010 with an Outlook 2010 calendar. It is a two-way synchronization, which means that when you add or modify events in SharePoint or in Microsoft Outlook 2010, those events appear in both applications after the next synchronization. You can also display multiple calendar lists together on the same page. You can display up to ten calendars, each with a different color, on the same page. For example, you can display two SharePoint calendars together on the same page.

Figure 1. Example SharePoint calendars in overlay mode

Example SharePoint calendars in overlay mode

Example 2: My Calendar Web Part on a SharePoint Page

Add a My Calendar Web Part to a SharePoint page to display calendar events that are stored on the computer that is running Microsoft Exchange Server. Individual team members can use the My Calendar Web Part to display their own calendars on their own sites, or you can use the Web Part to display a shared team calendar. For more information, see Adding and Configuring the My Calendar Web Part.

Example 3: Custom Calendar Web Part on a SharePoint Page

Add a custom calendar Web Part to a SharePoint page by extending the My Calendar Web Part and adding custom code.

Example 4: Page Viewer Web Part that Displays a Shared Exchange Calendar

Configure a Page Viewer Web Part to display a shared Exchange calendar on a SharePoint page. The Page Viewer Web Part is basically an HTML IFRAME element that can view a webpage, such as an Microsoft Outlook Web App calendar page, as shown in Figure 2.

Figure 2. Example Page Viewer Web Part showing a Calendar in Outlook Web App

Example Page Viewer Web Part showing a Calendar

Table 2 lists the Web Part properties that are required to display the Exchange calendar.

Table 2. Page Viewer Web Part Properties



Display Type (what you want to show)

Select Web Page (the default setting)


Basic URL Example:

Advanced URL Example: This example shows how to extend the URL to point to a specific account calendar module. For more information about how to use Outlook Web App Web Parts, or for more information about URL formats, see Additional Resources.

Example 5: Group Calendars

Use group calendars in SharePoint 2010 to add resources to a single calendar. Group calendars are a great addition to SharePoint. They are offered as part of the Group Worksite template, and enable project managers to add conference rooms, book resources, or even add people, as shown in Figure 3.

Figure 3. Example Group Calendar

Example Group Calendar

These are only some of the many ways that you can use the calendar-specific features in SharePoint.

The next section examines how to add and configure the My Calendar Web Part to display it on a SharePoint page.

Adding and Configuring the My Calendar Web Part

Earlier, you learned that the My Calendar Web Part is available in SharePoint Server 2010 Standard edition or SharePoint Server 2010 Enterprise edition, but not available in SharePoint Foundation 2010. The My Calendar Web Part (and several other Web Parts), is available as part of the Outlook Web App Web Parts, as shown in Figure 4.

Figure 4. My Calendar Web Part

My Calendar Web Part

The My Calendar Web Part is stored in the Web Part gallery on the site collection level in a file that is named owacalendar.dwp.

To access the Web Part gallery, follow these steps:

  1. Click Site Actions and then click Site Settings.

  2. In the Galleries section, choose Web Parts to display the list of Web Parts available in your SharePoint site collection Web Part gallery (see Figure 5).

Figure 5. My Calendar Web Part in the site collection Web Part gallery

My Calendar Web Part in Site Collection gallery

You can view the Web Part in the gallery, or you can export its XML definition file.

To export the Web Part, follow these steps:

  1. Select the Web Part that is named owacalendar.dwp in the gallery.

  2. In the Documents tab of the ribbon, click View Properties.

  3. Click the name, and if you are prompted, save the file to your desktop. The name of the Web Part is linked to its XML definition file, and its file name extension is .dwp.

If you open the definition file, you see the following XML.

<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns="">
<Assembly>Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<Title>My Calendar</Title>
<Description>Displays your calendar using Outlook Web Access for Microsoft Exchange Server 2003 or later.</Description>

The preceding XML definition file is a My Calendar Web Part that is not configured. You can add this Web Part to your site, configure it, and then export it. If you do this, notice that SharePoint adds more configuration elements to it. New Web Parts built for SharePoint 2010 have a .webpart file name extension instead of a .dwp file name extension. You can open files that have a .dwp file name extension only because of backward compatibility.

Table 3 lists the Web Part main XML elements.

Table 3. OWA calendar definition file main elements




The root element of a Web Part definition file. It encapsulates the rest of the definition.


This is the DLL file or assembly that contains the actual compiled code of the Web Part. This DLL file is loaded into memory by the runtime. This assembly has other namespaces and classes.


This element is what specifies the actual class or implementation of the Web Part. In this case, it is the OWACalendarPart class.

To add and configure the My Calendar Web Part, follow these steps:

  1. Click Site Actions and then click Edit Page.

  2. On the ribbon, select the Insert tab in Page Tools.

  3. Click the Add a Web Part link in the middle of the Web Part zone.

  4. Under the Categories list box, select the Outlook Web App category and choose My Calendar from the Web Parts list that is next to it, as shown in Figure 6.

    Figure 6. Adding My Calendar Web Part to a SharePoint page

    Adding My Calendar Web Part to a SharePoint page

  5. Click Add to add the Web Part to the Web Parts pane on the page.

After the Web Part is added to the Web Parts area on the page, you can configure it.

To configure the Web Part to display your Exchange calendar, follow these steps:

  1. Click the open the tool pane link that is displayed in the middle of the Web Part.

  2. Look at the Web Part properties. In Mail Configuration, do the following:

    1. Type the mail server information. Mail server information is your Outlook Web App endpoint. For example, your URL might be

    2. Type the mailbox information. The email account can be yours or a shared account, but it must be a valid corporate email account such as

    3. Select a daily or weekly view of your calendar, and then click OK.

Figure 7. My Calendar Web Part properties

My Calendar Web Part properties

If you are logged on to your network, you should be able to see your calendar without having to sign in again after you perform the preceding steps.

Figure 8. My Calendar Web Part

My Calendar Web Part

By default, the My Calendar Web Part does not render in full. You can update the appearance of the Web Part by increasing the value of its Height and Width properties. The mailbox information is optional if you are using the Web Part to view your own calendar. The My Calendar Web Part can translate your credentials, including your email account, and pass that information on to your corporate Exchange server.

The My Calendar Web Part is now ready to use. It is synchronized with your Outlook calendar, and you can display different calendar views, or create or delete an appointment, as shown in Figure 9.

Figure 9. My Calendar Web Part toolbar

My Calendar Web Part toolbar

If you export this Web Part, notice that SharePoint adds several new elements to the Web Part definition file. The following example shows an exported Web Part definition file that has the <Width> element and the <Height> element in addition to the Outlook Web App server root (<OWAServerAddressRoot xmlns="urn:schemas-microsoft-com:owapart">) element and the email address (<MailboxName xmlns="urn:schemas-microsoft-com:owapart">) element that is used during the configuration.

<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsi="" xmlns:xsd="" xmlns="">
  <Title>My Calendar</Title>
  <Description>Displays your calendar using Outlook Web App for Microsoft Exchange Server 2003 or later.</Description>
  <HelpLink />
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <IsIncludedFilter />
  <Assembly>Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <MailboxName xmlns="urn:schemas-microsoft-com:owapart"></MailboxName>
  <ViewName xmlns="urn:schemas-microsoft-com:owapart">Daily</ViewName>

You can modify these settings and reimport the Web Part to the Web Part gallery if you want to share your configuration and enable other people to use your Web Part.

The next section explains how to extend the basic functionality of the My Calendar Web Part.

Extending the My Calendar Web Part

To extend the base functionality of the My Calendar Web Part, you must have access to Visual Studio 2010 to create custom code that can be deployed to your SharePoint site. This section shows how to create a custom Web Part that inherits from the OWACalendarPart class. This class is part of the Microsoft.SharePoint.WebControls namespace, and can be found in the Microsoft.SharePoint.Portal.dll assembly.

To create a custom Web Part class, follow these steps:

  1. Open Visual Studio 2010 as an administrator, and create an Empty SharePoint 2010 Project. Name the project Company.MyCustomCalendarPart, and then click OK.

    Figure 10. Custom My Calendar Web Part SharePoint 2010 Project

    Custom My Calendar Web Part SharePoint Project

  2. Click the Deploy as a farm solution option and then click Finish.

    Figure 11. Choose Farm solution

    Choose Farm solution

  3. Right-click your project name in Solution Explorer, click Add, and then click New Item. Choose the Web Part item type. In the Name field, type MyCalendarWebPart and then click Add, as shown in Figure 12.

    Figure 12. Create Web Part SharePoint project item

    Create Web Part SharePoint Project Item

  4. Add Microsoft.SharePoint.Portal.dll reference to your project. If your development computer is also your SharePoint server, browse to the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\ folder and select the assembly. If not, copy it from your SharePoint server and place it on your file system.

  5. In the MyCalendarWebPart code file, replace the base class name WebPart with OWACalendarPart.

  6. Add the following using statement at the top of your MyCalendarWebPart.cs file.

    using Microsoft.SharePoint.Portal.WebControls; 

    The using statement enables the Visual Studio compiler and the runtime to resolve the OWACalendarPart class.

  7. Replace the CreateChildControls method and its contents with the following code example, which shows a simple way that you can start to override some of the public members in the OWACalendarPart class. In particular, the code example preconfigures the Web Part so that you and your users don’t have to configure it every time that you add it to a SharePoint page.

    protected override void CreateChildControls()
                //  TODO
                //  Add Your custom code here.
                //  Example overrides.
                //  The Exchange OWA endpoint.
                this.OWAServerAddressRoot = "";
                //  By default, the calendar is the folder this Web Part 
                //  is configured to show.
                //  this.ExchangeFolderName = "Calendar";
                //  There are two View types you can use here. The Daily 
                //  View is the default. Use Weekly instead.
                this.ViewName = "Weekly";
                //  The base part provides the logged-on user email 
                //  account by default. 
                //  this.MailboxName = "";
  8. You must rename the Web Part definition file because the assembly used is Microsoft.SharePoint.Portal, and when SharePoint tries to load Web Parts from that assembly, it requires them to have a definition file that has a .dwp file name instead of a .webpart file name extension. In addition, the .dwp file requires certain XML elements for SharePoint to verify the schema.

    1. Right-click the .webpart file MyCalendarWebPart.webpart, and rename it MyCalendarWebPart.dwp.

    2. Open the MyCalendarWebPart.dwp file and replace its contents with the following code.

      <?xml version="1.0" encoding="utf-8"?>
      <WebPart xmlns="">
        <Assembly>Company.MyCustomCalendarPart, $SharePoint.Project.AssemblyFullName$</Assembly>
          <TypeName>Company.MyCustomCalendarPart.MyCalendarWebPart.MyCalendarWebPart, $SharePoint.Project.AssemblyFullName$</TypeName>
        <Description>My WebPart</Description>

      You must replace the contents of the .dwp file to ensure that SharePoint loads the correct Web Part definition file that contains the Web Part v2 schema information because the functionality in the Web Part relies on the SharePoint Portal namespace.

  9. Double-click the Elements.xml file, and replace its contents with the following code. Notice the .dwp file name extension on the Web Part file. Replacing the original content ensures that you have the correct values in the Path attribute of the File element as well as in the URL. Another option is to take what you must have and replace only those values in the file that you have.

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="" >
      <Module Name="MyCalendarWebPart" List="113" Url="_catalogs/wp">
        <File Path="MyCalendarWebPart\MyCalendarWebPart.dwp" Url="MyCalendarWebPart.dwp" Type="GhostableInLibrary">
          <Property Name="Group" Value="Custom" />
  10. Check your work. Your class, solution, and files should match those shown in Figure 13.

    Figure 13. Custom My Calendar Web Part Solution

    Custom My Calendar Web Part Solution

  11. Save all your work, and then press F5 to start the deployment. Visual Studio 2010 connects to your SharePoint site, and then retracts and deploys your solution. If you are prompted to modify the web.config file to enable debugging, click OK, and then continue, as shown in Figure 14. Visual Studio 2010 opens a new browser window that you can use to navigate to the Web Part gallery and add your Web Part, as shown in Figure 15.

Figure 14. Adding Custom My Calendar Web Part

Adding Custom My Calendar Web Part

Figure 15. Allow Debugging in Web.Config

Allow Debugging in Web.Config

About the Author

Johnny Harbieh is a Lead Consultant who works for Avtex Solutions LLC, a leading Microsoft partner that optimizes client interactions by using technologies based on the Microsoft platform. As an experienced Information Worker consultant, Johnny focuses on the SharePoint platform and what it brings to his clients. His work ranges from Strategy Briefings, Planning and Architecture, to Development, Deployment and Support of SharePoint-based solutions. Johnny holds several certifications in .NET, SQL Server, and the Portals and Collaboration space, including MCTS and MCITP in SharePoint Foundation and Server 2010. Johnny can be reached at or on Twitter as @jharbieh. Johnny also keeps a public blog.

The following were tech editors on Microsoft SharePoint 2010 articles from Wrox:

  • Matt Ranlett is a SQL Server MVP who has been a fixture of the Atlanta .NET developer community for many years. A founding member of the Atlanta Dot Net Regular Guys, Matt has formed and leads several area user groups. Despite spending dozens of hours after work on local and national community activities, such as the SharePoint 1, 2, 3! series, organizing three Atlanta Code Camps, working on the INETA board of directors as the vice president of technology, and appearing in several podcasts such as .Net Rocks and the ASP.NET Podcast, Matt recently found the time to get married to a wonderful woman named Kim, whom he helps to raise three monstrous dogs. Matt currently works as a senior consultant with Intellinet and is part of the team committed to helping people succeed by delivering innovative solutions that create business value.

  • Jake Dan Attis. When it comes to patterns, practices, and governance with respect to SharePoint development, look no further than Jake Dan Attis. A transplant to the Atlanta area from Moncton, Canada, Dan has a degree in Applied Mathematics, but is 100% hardcore SharePoint developer. You can usually find Dan attending, speaking at, and organizing community events in the Atlanta area, including code camps, SharePoint Saturday, and the Atlanta SharePoint User Group. When he's not working in Visual Studio, Dan enjoys spending time with his daughter Lily, watching hockey and football, and sampling beers of the world.

  • Kevin Dostalek has over 15 years of experience in the IT industry and over 10 years managing large IT projects and IT personnel. He has led projects for companies of all sizes and has participated in various roles including Developer, Architect, Business Analyst, Technical Lead, Development Manager, Project Manager, Program Manager, and Mentor/Coach. In addition to these roles, Kevin also managed a Solution Delivery department as a Vice President for a mid-sized MS Gold Partner from 2005 through 2008 and later also served as a Vice President of Innovation and Education. In early 2010 Kevin formed Kick Studios as a company providing consulting, development, and training services in the specialized areas of SharePoint and Social Computing. Since then he has also appeared as a speaker at numerous user group, summit, and conference type events across the country. You can find out more about Kevin on his blog, The Kickboard.

  • Larry Riemann has over 17 years of experience architecting and creating business applications for some of the world’s largest companies. Larry is an independent consultant who owns Indigo Integrations and does SharePoint consulting exclusively through SharePoint911. He is an author, writes articles for publication and occasionally speaks at conferences. For the last several years he has been focused on SharePoint, creating and extending functionality where SharePoint leaves off. In addition to working with SharePoint, Larry is an accomplished .Net Architect and has extensive expertise in systems integration, enterprise architecture and high availability solutions. You can find him on his blog.

  • Sundararajan Narasiman is a Technical Architect with Content Management & Portals Group of Cognizant Technology Solutions, Chennai, with more than 10 years of Industry Experience. Sundararajan is primarily into the Architecture & Technology Consulting on SharePoint 2010 Server stack and Mainstream .NET 3.5 developments. He has passion for programming and also has interest for Extreme Programming & TDD.

Additional Resources

For more information about the topics, concepts, and features in this article, see the following resources: