Tag Archives: VSTO

Office Developer: Difference between Office Web addin vs COM/VSTO addin


COM or VSTO add-ins are earlier Office integration solutions that run only on Office for Windows. The major difference what you see is that COM addins will be running in the user device or in the Office Client. The new Office Add-ins don’t involve code that runs on the user’s device or in the Office client. For an Office Add-in, the host application, for example Excel, reads the add-in manifest and hooks up the add-in’s custom ribbon buttons and menu commands in the UI. When needed, it loads the add-in’s JavaScript and HTML code, which executes in the context of a browser in a sandbox.

Components of a Hello World add-in

In general, Office Add-ins provides advantages over add-ins built using VBA, COM, or VSTO. I can name few of them,

  • Cross-platform support:
    Office Add-ins run in Office for Windows, Mac, iOS, and Office Online. So your solution can run in Office across multiple platforms, including Office for Windows, Office Online, Office for the Mac, and Office for the iPad.

  • Single sign-on (SSO):
    Office Add-ins integrate easily with users’ Office 365 accounts.

  • Centralized deployment and distribution:
    Admins can deploy Office Add-ins centrally across an organization.

  • Easy access via AppSource:
    You can make your solution available to a broad audience by submitting it to AppSource.

  • Based on standard web technology:
    You can use any library you like to build Office Add-ins

Hope this helps.

Office 365 Dev: Connecting Microsoft Graph with Visual Studio 2017


If you have connected Microsoft Graph with previous Visual Studio to build application, then you can do the same steps with latest Visual Studio 2017 preview as well. Using Visual Studio, you can now easily configure your projects to access data across Office 365 and Azure Active Directory through the Microsoft Graph.

image

– First you can download & install the latest Visual Studio 2017 Preview.
– Second, when you open or create a project in Visual Studio, you will see Connected Services in the Solution Explorer.
– Third, Clicking on it will take you to the Connected Services tab, in which you will see the “Access Office 365 Services with Microsoft Graph” provider.
– Now you’re good to go!!

image

As you aware Microsoft Graph serves as the single gateway for developers to access APIs for Exchange, SharePoint, Azure AD, OneNote, Planner, Excel, and more. It provides one REST API endpoint across all of Microsoft’s APIs, and includes access to insights and relationship analysis powered by its intelligent engine. This means that you no longer have to integrate individual Microsoft services separately into your apps, enabling you to leverage many different services easily and efficiently.

Hope this helps.

New name for Apps for Office and SharePoint? Office and SharePoint Add-ins


As you aware that you can use Office and SharePoint Add-ins to extend Office applications with content directly from the web or to extend SharePoint websites. But do you know the “new name” for “apps for Office and SharePoint”? Yes, the platform name will be changed from "apps for Office and SharePoint" to "Office and SharePoint Add-ins". Currently the related products, documentation, samples, and other resources are getting updated to reflect the change – so that this change will help better distinguish the extension platform from Office Add-ins (applications). The following table lists the names that are changing and the new names:

Le Café Central de Deva

In Office Developer tools for Visual Studio (Office Web apps, VSTO, COM add-ins) it will be further differentiated as the following:

 Le Café Central de Deva

Hope this helps.

Recycling bits : Developer roadmap for Office 2007


Recently one of my customer(developer) is looking for Developer roadmap for Office 2007 and its relevant documents. During the search, i found the following information and want to share with you.

There are lot of new technologies like [ribbon customizations, XML file formats, Outlook form regions, SharePoint workflow support, VSTO changes]. To learn more on this, download the Office 2007 Developer roadmap from here with respect to every Office Developer.

Why my VSTO Outlook add-in works in Dev box, not in non-dev or production boxes?


Recently one of my customer reported (we used to see this is many of the developer have is that their assembly does not execute as expected in non-development boxes – why it so?) that initially they tried they created VSTO Outlook Add-in project solution with the helps of Visual Studio 2005. But  when they move it to another machine it fails to load.


In these type of general troubleshooting steps, you can check couple of relevant things, as i found in the blogpost:



  1. Network rule is correct – Don’t assume, http://server/ –> FullTrust –> always added to the MyComputer zone. It’s in  LocalIntranet

  2. Errorneous URL – Typo/Error in the filename or URL

  3. Asterisk (*) was not added – After a directory to indicate “and all folders under here”

Later i jumped into the analysis & debugging part i noticed that that policy was not updated correctly. To rectify that i tried the following:


caspol -all -lg


caspol -rsg path_to_assembly


i) the security policy looks like, lg –> list groups & all policy rules
ii) then CLR thinks the evidence of the assembly maps to those rules like, rsg –> resolve groups & list groups the assembly matches.


Certainly this will tell us whether the customer have set up policy correctly or not. Also this will help us to identify their assembly is matching the code groups, should match or not.


Happy VSTO troubleshooting!!

Outlook Object Model : Why i can’t able to assign value for MAPIFolder.WebViewURL ?


One of my customer had created an Outlook Add-in using VSTO & Outlook Object Model (OOM). As per the business logic, he need to implement the WebViewURL in it. The MAPIFolder.WebViewURL works fine and take’s us to set value to it most of the times, but it doesn’t function as expected in some time; the strange thing is it’s not throwing any error or exception when we execute the code.

//[Code Snippet : C# , VSTO, Outlook Object Model (OOM)]
...
//Provide the non-default store path
String pstPath = @"providelocalpath like c:personals.pst";
 
MAPIFolder _pstFolder;
//Add the PST
this.Application.Session.AddStoreEx(pstPath, OlStoreType.olStoreDefault);
_pstFolder = this.Application.Session.Folders[2];
 
//Provide PSTFolder Name
_pstFolder.Name = "SampleFolder";
 
//Set the values
MAPIFolder mf = _pstFolder.Folders.Add("MyHtmlView", Type.Missing);
 
//Assign value for MAPIFolder.WebViewURL
mf.WebViewURL = "http://www.microsoft.com";
mf.WebViewOn = true;
...

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

MAPIFolder.WebViewURL Property (Microsoft.Office.Interop.Outlook) Returns or sets a String (string in C#) indicating the URL of the Web page that is assigned to a folder. Read/write.

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.webviewurl.aspx

When we start troubleshooting the case, we found that the issue happens for the non-default stores.

During research we found couple of community blog post references, Randy & Ryan’s MS Press book that with respect to Microsoft Office Outlook 2007, the home page setting is disabled for non-default stores. Non-default stores can include Personal Folders files (.pst) or the Microsoft Windows SharePoint Services folders. These folders are also stored in a .pst file. To see the home page setting for a non-default store, right-click the store in the Navigation Pane, click Properties, and then click the Home Page tab.

By default, you cannot type or paste a URL in the Address box. This issue occurs because, by default, home pages are disabled for non-default stores. To overcome this issue, we don’t have any programmatic resolution; but we can implement the resolution by refer the following support KB.

Outlook 2007 SP2’s application shutdown changes


I went through Ryan’s MSDN article, where we can learn how Microsoft Office Outlook 2007 Service Pack 2 has changed the way that the Outlook process shuts down. Customers developing Outlook solutions that run outside of the Outlook process should understand these changes and the impact on their solutions.

Prior to Outlook 2007 SP2, Outlook followed the best practices for Component Object Model (COM) servers and allowed clients of the Outlook COM server to control the shutdown of the Outlook process. This caused a significant end-user side effect: often the end user could not close Outlook because of lingering external references from Outlook.

As a result of customer feedback about the need to close Outlook and have Outlook stop running, Outlook 2007 SP 2 changes the way Outlook closes, ensuring that the intent of the end user─to close Outlook─is respected. These changes significantly affect the way that the Outlook COM server shuts down, which can impact solutions using the Outlook object model outside of the Outlook process.

Impact for Add-ins

If your solution is an in-process COM add-in, or if you used Microsoft Visual Studio Tools for Office to write an add-in for Outlook, this change does not affect the way that Outlook and your add-in work together. The lifetime of in-process add-ins and in-process COM references to Outlook objects in Outlook 2007 is the same as the lifetime of the Outlook process. When the user closes the last Outlook window and Outlook starts to close, Outlook disconnects add-ins and releases all of their references to Outlook.

Add-ins can use the Quit event on the Application object to determine when Outlook closes down. After Outlook raises the Quit event, the OnDisconnection method of the IDTExtensibility2 interface of the add-in or the Shutdown method of the ThisAddin class of the Visual Studio Tools for Office add-in will be called, the add-in will be unloaded, and Outlook will close.

Impact for Solutions

In versions of Outlook earlier than Outlook 2007 SP2, before Outlook closed, Outlook would check for external, out-of-process references on its COM server and wait for those references to be released. This allowed out-of-process solutions that depended on Outlook data to keep Outlook running until the references were released. This is a common behavior for COM servers; however, this is unexpected behavior for end users, who expect that an application will close when they close the last window of the application.

By default, Outlook 2007 SP2 ignores external COM references when determining if it should close. When an end user closes the last Outlook window on the user’s computer, Outlook starts closing down the process: first raising the Quit event on the Application object, then disconnecting add-ins and external references, followed by flushing internal caches to disk, and finally exiting its process.

Because of the way COM works, when Outlook releases external references, these referenced objects become disconnected objects in cross-process solutions. Without being aware that previously referenced objects have been disconnected by Outlook, a solution that attempts to use any of these object references will receive an error, RPC_E_DISCONNECTED. Solutions that are not designed to handle this error may stop responding or respond unexpectedly. This occurs when a solution attempts to use an object reference to Outlook after Outlook has closed and disconnected all previous references to the object.

To work properly with the new behavior in Outlook, a solution should listen for the Quit event on the Application object. When that event is raised, the solution should stop any work in progress that uses Outlook data, and release all references to Outlook. Any remaining references after the solution returns from the Quit event will be disconnected. The solution should no longer use any of these disconnected references since any operation will result in an error. If the solution subsequently needs to access data from Outlook, it can request a new instance of the Application object by using the CoCreateInstance function, which will start Outlook without any user interface as described below. However, this should be avoided because the end user has closed Outlook.

Note: The solution should be aware of the Windows shut-down events, and should not attempt to invoke a new instance of Outlook if Outlook is shutting down because Windows is shutting down.

While a solution is handling the Quit event, Outlook can appear to have stopped responding to the end user and the operating system. The end user may forcibly terminate Outlook instead of waiting for it to finish closing. Therefore, the solution should handle and return from the Quit event as quickly as possible.

As a result of this change, solutions may work differently on Outlook 2007 SP2. Solutions providers may need to update their solutions so that they work properly with the new behavior in Outlook 2007 SP2.

OOM & VSTO : How to capture the current item from the active inspector?


One of my customer (developer) updated and created an Outlook 2007 Add-in (VSTO). He want to capture the current item from the active inspector?

In order to capture the current item from the active inspector you can use “OutlookSession.ActiveInspector.CurrentItem”. It will like this,

'[VB.Net: Code Snippet]
...
'Declaration part
Dim ThisOutlookSession As Outlook.Application = New Outlook.Application
Dim NS As Outlook.NameSpace = ThisOutlookSession.Session
 
... 
'Implement your business logic, if you have any
...
'Find whether the active window is the Inspector or not
If TypeName(ThisOutlookSession.ActiveWindow) = "Inspector" Then 
         Msgbox(ThisOutlookSession.ActiveInspector.CurrentItem.Subject)
End if
...

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Screencast: Outlook Context Menus and Creating a Meeting from an Email


Please view this wonderful Screencast from channel9, which easily we can able to create our own menu option to the context menu in Outlook.

Per jwiese "…would you like to add your own menu option to the context menu in Outlook?  How about turning an email into a new meeting request without having to type in all the attendees or the body and subject?  Well, in this Screencast I’ll show you how to add to the context menu and generate a meeting request that includes the email’s recipients, subject and body in the meeting details…"

Download: Outlook 2007 Add-ins & code samples


Whenever we discuss with regards to Outlook Add-in customization, many of our customer(s) or their developers want to customize it according to their requirements. Also they look for the code-samples, related articles to proceed further. In this discussion, i have added couple of Outlook 2007 specific add-ins, code samples along with their download links.


Please download the following Outlook add-ins along with the code-samples:


Outlook 2007 Add-Ins: RulesAddin, TravelAgencyAddin, and PrepareMeAddin
Download: http://www.microsoft.com/downloads/details.aspx?FamilyId=F871C923-3C42-485D-83C7-10A54A92E8A2&displaylang=en

Please note: The Outlook 2007 Sample Add-Ins are a learning tool that will help you understand some of the important new features in the Outlook 2007 object model. Each sample is available in a version for Visual Studio 2005 Tools for Office Second Edition (VSTO 2005 SE) in addition to the version based on the Outlook 2007 Sample: Visual Studio 2005 Templates.


They provide coverage of the following important new areas:



  • Using the Rules object model, which allows you to programmatically create or access most rules supported by the Outlook Rules Wizard (Rules sample)

  • Implementing a form region for an Outlook contact item (Travel Agency sample)

  • Adding a custom task pane to an Outlook AppointmentItem (Prepare Me sample)

Outlook 2007 Sample: Ribbon Extensibility Add-In
Download: http://www.microsoft.com/downloads/details.aspx?FamilyID=11ab93bf-48dc-4f73-8f6b-62b4482a92bc&displaylang=en

Please note: The Outlook 2007 Ribbon Extensibility Add-In is a learning tool that will help you understand how to customize the Ribbon for Outlook Inspector windows. It provides coverage of the following important new areas:



  • How legacy command bar customizations appear in an Outlook Inspector window

  • How to implement the Office.IRibbonExtensibility interface in an Outlook add-in

  • Providing Ribbon markup for Ribbon customization depending on the RibbonID string passed in the GetCustomUI callback

  • Using the IRibbonControl.Context object to find an instance of an Inspector object

  • Changing the state of Ribbon controls depending on the PropertyChange event for an Outlook item.

Outlook 2007 Sample: Visual Studio 2005 Templates
Download: http://www.microsoft.com/downloads/details.aspx?familyid=0cab159a-0272-4635-b158-10553779a3df&displaylang=en

Please note: The Outlook 2007 Add-in Templates provide a basic template for developing Outlook 2007 add-ins using Visual Studio 2005. The templates are available in both Visual Basic and Visual C# languages. Each template includes the OutlookItem class, which enables developers to work with generic Outlook items through late-binding, without determining the item type first.


The templates also include wrapper classes that enable you to track multiple Outlook Inspector or Explorer windows. The templates provide an alternative to the Outlook add-in templates available with Microsoft Visual Studio 2005 Tools for the 2007 Office system (VSTO 2005 Second Edition). VSTO 2005 SE is the preferred tool for developing add-ins for Outlook 2007. If you choose to build your add-in by using the Outlook 2007 Add-In Templates, you must add a COM Shim project and a Setup project to your add-in solution.


Outlook 2007 Add-In: Form Region Add-In
Download: http://www.microsoft.com/downloads/details.aspx?familyid=932b830f-bf8f-41fc-9962-07a741b21586&displaylang=en

Please note: The Outlook 2007 Form Region Add-ins are a learning tool that will help you understand how to design, build, and run custom form solutions based on Outlook form regions. They provide coverage of the following important new areas:



  • Tracking the state of a form region across multiple windows

  • Implementing the FormRegionStartup interface in an Outlook add-in

  • Understanding the form region manifest XML

  • Registering a form region with Outlook

  • Storing form components as a project resource

  • Deploying a form region solution

Outlook 2007 Sample: What’s New Add-Ins
Download: http://www.microsoft.com/downloads/details.aspx?FamilyId=AABF127D-D069-4549-A1B1-667A698C3EF6&displaylang=en

Please note: The Outlook 2007 What’s New Add-Ins are a learning tool that will help you understand some of the important new features in the Outlook 2007 object model. They provide coverage of the following important new areas:



  • Context menu customization

  • The Table object model and Instant Search queries

  • The PropertyAccessor object that allows getting or setting properties that are not explicitly exposed in the Outlook object model

  • The Rules object model that allows programmatically creating or accessing most rules supported by the Outlook Rules Wizard

  • The SelectNamesDialog object that displays the Outlook Address Book and lets you customize the dialog caption and recipient selectors

  • Enhancements to the AddressEntry and AddressList objects, including the ExchangeUser and ExchangeDistributionList objects that allow getting and setting properties of an Exchange user or Exchange distribution list.

Outlook VSTO add-in won’t run when you use Outlook view control from Web page?


Do you know that when you use the Microsoft Outlook View Control from a Web page, Microsoft Visual Studio Tools for the Microsoft Office System (VSTO) Outlook add-ins do not run.

This issue may occur even by this option: The Outlook View Control is not considered a part of the Outlook user interface. Therefore, the VSTO add-ins do not load correctly.

For more detailed information, please go through the following KB article.

Outlook Programming Series # 10 : How to customize Outlook 2007 Ribbons?


Welcome to Outlook Programming series  # 10


In this series, we will learn “How to customize Outlook 2007 (Office 2007) Ribbon functionality”. I found these below given MSDN articles which describes how we can customize Office 2007 (including Outlook 2007) ribbon functionality.