name 'application' does not exist in the current context
outlook, ribbon, vsto
Solution
An instance of Application can be accessed using `Globals.ThisAddIn.Application`. If you renamed your AddIn class to something different e.g. MyAddIn then the command will be: `Globals.MyAddIn.Application`.
Here is a link with more details: http://msdn.microsoft.com/en-us/library/vstudio/bb157876(v=vs.100).aspx
Problem
Hi I'm working to develop a solution to creating a toolbar in Outlook 2010 using VSTO 2012 and the microsoft outlook 2010 addin. In a nutshell I am able to create the Outlook ribbon and a button but I am unable to get the button to open an .oft file. In Visual Studio I get the following error "The name 'application' does not exist in the current context". I have added a reference to the Microsoft Office 14.0 Object Library also. Below is the code... ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Outlook = Microsoft.Office.Interop.Outlook; using Office = Microsoft.Office.Core; using Microsoft.Office.Tools.Ribbon; namespace OutlookAddIn8 { public partial class Ribbon1 { private void Ribbon1_Load(object sender, RibbonUIEventArgs e) { } private void CreateItemFromTemplate() { Outlook.Folder folder = Application.Session.GetDefaultFolder( Outlook.OlDefaultFolders.olFolderDrafts) as Outlook.Folder; Outlook.MailItem mail = Application.CreateItemFromTemplate( @"c:\ivy.oft", folder) as Outlook.MailItem; mail.Subject = "Congratulations"; mail.Save(); } private void button1_Click(object sender, RibbonControlEventArgs e) { } } ``` } Thanks any help is appreciated it is probably something simple thats been missed.