none
System.Windows.Forms.Application' does not contain a definition for 'Session' RRS feed

  • Question

  • Please tell me why "Session" is giving me an error.

    using System.Text;
    using System.Windows.Forms;
    using Outlook = Microsoft.Office.Interop.Outlook;
    namespace WindowsFormsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                try
                {
                    Outlook.Folder folder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderRssFeeds) as Outlook.Folder;

    Friday, August 31, 2012 8:43 PM

Answers

  • Differnt Application object. There can be many, depending on the context. As this is a VSTO forum, use the Application object that's current in this.Application in your ThisAddin class.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Selman13" <=?utf-8?B?U2VsbWFuMTM=?=> wrote in message news:7a5e2454-4b47-4d12-937f-bda22496ee1d...

    Please tell me why "Session" is giving me an error.

    using System.Text;
    using System.Windows.Forms;
    using Outlook = Microsoft.Office.Interop.Outlook;
    namespace WindowsFormsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                try
                {
                    Outlook.Folder folder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderRssFeeds) as Outlook.Folder;


    Ken Slovak MVP - Outlook
    Friday, August 31, 2012 9:46 PM

All replies

  • Differnt Application object. There can be many, depending on the context. As this is a VSTO forum, use the Application object that's current in this.Application in your ThisAddin class.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Selman13" <=?utf-8?B?U2VsbWFuMTM=?=> wrote in message news:7a5e2454-4b47-4d12-937f-bda22496ee1d...

    Please tell me why "Session" is giving me an error.

    using System.Text;
    using System.Windows.Forms;
    using Outlook = Microsoft.Office.Interop.Outlook;
    namespace WindowsFormsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                try
                {
                    Outlook.Folder folder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderRssFeeds) as Outlook.Folder;


    Ken Slovak MVP - Outlook
    Friday, August 31, 2012 9:46 PM
  • as Ken said - there is namespace clashing between Windows.Forms and Interop.Outlook. You should prepend your call to Application (in this particular context) with Outlook. But there is also different problem - if this is your starting point you should instantiate Outlook'a application object first. Or is this form used inside Add-in project?

    Saturday, September 1, 2012 4:57 AM
  • To fix the error do the following. You have to create a OutlookApplication object before you can use it in a standalone application. (Microsoft example is for an outlook plugin)

     private void GetApptTimeButton_Click(object sender, EventArgs e)
            {
                Outlook.Application OutlookApplication = new Outlook.Application();
                Outlook.Folder calFolder =
                    OutlookApplication.Session.GetDefaultFolder(
                        Outlook.OlDefaultFolders.olFolderCalendar)
                        as Outlook.Folder;

    ....

    Friday, March 25, 2016 6:41 PM