none
Having Trouble attaching a pst in outlook 2013 - VSTO Addin RRS feed

  • Question

  • hi there, i'm trying to attach a pst file, but am having issues with the below code in a separate class.

    the error i get is on outlook.application.GetNamespace("MAPI") and it says: An object reference is required for the non-static field, method or property (microsoft.office.interop._Application.GetNamespace(string)

    im not quite sure what im doing wrong - can someone please explain this or point me in the right direction?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    using Outlook = Microsoft.Office.Interop.Outlook;
    using System.Reflection;
    using System.Runtime.InteropServices;
    
    namespace OutlookTools
    {
        public class Archive
        {        
            public void addArchive(string pstFileName)
            {            
                Outlook.NameSpace ns = Outlook.Application.GetNamespace("MAPI");
                ns.AddStore(pstFileName);           
            }
        }
    }

    Monday, April 22, 2013 8:25 AM

Answers

All replies