c# - Outlook code compile error due to `Application` reference missing -


i trying write c# code interact outlook 2010. using this example microsoft.

my code follows:

using system; using system.text;          // stringbuilder using system.diagnostics;   // debug  using system.linq; using system.reflection; using system.runtime.interopservices;  using outlook = microsoft.office.interop.outlook;  namespace directreports {     public class program     {         private void getmanagerdirectreports()         {             outlook.addressentry currentuser = application.session.currentuser.addressentry;             //outlook.addressentry currentuser = outlook.application.session.currentuser.addressentry;             if (currentuser.type == "ex")             {                 outlook.exchangeuser manager = currentuser.getexchangeuser().getexchangeusermanager();                 if (manager != null)                 {                     outlook.addressentries addrentries =                         manager.getdirectreports();                     if (addrentries != null)                     {                         foreach (outlook.addressentry addrentry                             in addrentries)                         {                             outlook.exchangeuser exchuser = addrentry.getexchangeuser();                             stringbuilder sb = new stringbuilder();                             sb.appendline("name: " + exchuser.name);                             sb.appendline("title: " + exchuser.jobtitle);                             sb.appendline("department: " + exchuser.department);                             sb.appendline("location: " + exchuser.officelocation);                             debug.writeline(sb.tostring());                         }                     }                 }             }         }     } } 

the microsoft example mentions "if use visual studio test code example, must first add reference microsoft outlook 15.0 object library component". working in visual studio express 2013 windows desktop. did not see version 15.0 object library, added version 14.0 1 instead (which think right 1 outlook 2010 anyways):

references included

when attempt build, following error:

the name 'application' not exist in current context 

i read couple of references indicate application should part of above object libraries, not working here. can please suggest doing wrong?

you can create new application object:

var appoutlook = new microsoft.office.interop.outlook.application(); 

and use as:

outlook.addressentry currentuser = appoutlook.session.currentuser.addressentry; 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -