Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Outlook Addin Exception

Outlook Addin Exception

Scheduled Pinned Locked Moved C#
comtoolshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Walaza
    wrote on last edited by
    #1

    Hi everyone, I developed an Outlook Addin that is supposed to open a certain application depending on the subject of the Email that I receive. The app works fine but after clicking OK to all MessageBoxes, I get the ff error: Object reference not set to an instance of an object. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at Outlook_Drag_Try.ThisApplication.ThisApplication_Startup(Object sender, EventArgs e) in C:\Inetpub\wwwroot\DRAGGER\Outlook_Drag_Try\Outlook_Drag_Try\ThisApplication.cs:line 31 at Microsoft.Office.Tools.Outlook.Application.OnStartup() at Outlook_Drag_Try.ThisApplication.FinishInitialization() in C:\Inetpub\wwwroot\DRAGGER\Outlook_Drag_Try\Outlook_Drag_Try\ThisApplication.Designer.cs:line 65 at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecutePhase(String methodName) at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteCustomizationStartupCode() at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteEntryPointsHelper() at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.Microsoft.VisualStudio.Tools.Applications.Runtime.IExecuteCustomization2.ExecuteEntryPoints() ************** Loaded Assemblies ************** Here is my code: string filter = "ecs"; Outlook.NameSpace outlookNameSpace = this.GetNamespace("MAPI"); //Outlook.MAPIFolder inbox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); Outlook.MAPIFolder inbox = this.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); /*Retrieve and count unread messages from Inbox */ Outlook.Items items = inbox.Items; Outlook.Items unreadItems = inbox.Items.Restrict("[Unread]=true"); MessageBox.Show(string.Format("The number of Unread items in Inbox = {0}", unreadItems.Count)); // If the mail item matches the specified filter, // open The Dragger application foreach (Outlook.MailItem mail in items) { //if the mail's subject has ecs, open The Dragger if (mail.Subject.ToUpper().Contains(filter.ToUpper())) { //Open The Dragger MainForm main = new MainForm(); main.Sho

    L 1 Reply Last reply
    0
    • W Walaza

      Hi everyone, I developed an Outlook Addin that is supposed to open a certain application depending on the subject of the Email that I receive. The app works fine but after clicking OK to all MessageBoxes, I get the ff error: Object reference not set to an instance of an object. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at Outlook_Drag_Try.ThisApplication.ThisApplication_Startup(Object sender, EventArgs e) in C:\Inetpub\wwwroot\DRAGGER\Outlook_Drag_Try\Outlook_Drag_Try\ThisApplication.cs:line 31 at Microsoft.Office.Tools.Outlook.Application.OnStartup() at Outlook_Drag_Try.ThisApplication.FinishInitialization() in C:\Inetpub\wwwroot\DRAGGER\Outlook_Drag_Try\Outlook_Drag_Try\ThisApplication.Designer.cs:line 65 at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecutePhase(String methodName) at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteCustomizationStartupCode() at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteEntryPointsHelper() at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.Microsoft.VisualStudio.Tools.Applications.Runtime.IExecuteCustomization2.ExecuteEntryPoints() ************** Loaded Assemblies ************** Here is my code: string filter = "ecs"; Outlook.NameSpace outlookNameSpace = this.GetNamespace("MAPI"); //Outlook.MAPIFolder inbox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); Outlook.MAPIFolder inbox = this.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); /*Retrieve and count unread messages from Inbox */ Outlook.Items items = inbox.Items; Outlook.Items unreadItems = inbox.Items.Restrict("[Unread]=true"); MessageBox.Show(string.Format("The number of Unread items in Inbox = {0}", unreadItems.Count)); // If the mail item matches the specified filter, // open The Dragger application foreach (Outlook.MailItem mail in items) { //if the mail's subject has ecs, open The Dragger if (mail.Subject.ToUpper().Contains(filter.ToUpper())) { //Open The Dragger MainForm main = new MainForm(); main.Sho

      L Offline
      L Offline
      Le centriste
      wrote on last edited by
      #2

      Walaza wrote:

      at Outlook_Drag_Try.ThisApplication.ThisApplication_Startup(Object sender, EventArgs e) in C:\Inetpub\wwwroot\DRAGGER\Outlook_Drag_Try\Outlook_Drag_Try\ThisApplication.cs:line 31

      Could you point out this line in your code above?

      ----- Formerly MP(2) If atheism is a religion, then not collecting stamps is a hobby. -- Unknown

      W 1 Reply Last reply
      0
      • L Le centriste

        Walaza wrote:

        at Outlook_Drag_Try.ThisApplication.ThisApplication_Startup(Object sender, EventArgs e) in C:\Inetpub\wwwroot\DRAGGER\Outlook_Drag_Try\Outlook_Drag_Try\ThisApplication.cs:line 31

        Could you point out this line in your code above?

        ----- Formerly MP(2) If atheism is a religion, then not collecting stamps is a hobby. -- Unknown

        W Offline
        W Offline
        Walaza
        wrote on last edited by
        #3

        Hi Le Centriste, This is Line 31: //if the mail's subject is ecs, open The Dragger Application LINE 31--> if (mail.Subject.ToUpper().Contains(filter.ToUpper())) { //Open The Dragger MainForm main = new MainForm(); main.ShowDialog(); } else { MessageBox.Show("No New Messages For ECS!!!"); }

        Mvelo Walaza Jnr Developer Telkom SA

        L 1 Reply Last reply
        0
        • W Walaza

          Hi Le Centriste, This is Line 31: //if the mail's subject is ecs, open The Dragger Application LINE 31--> if (mail.Subject.ToUpper().Contains(filter.ToUpper())) { //Open The Dragger MainForm main = new MainForm(); main.ShowDialog(); } else { MessageBox.Show("No New Messages For ECS!!!"); }

          Mvelo Walaza Jnr Developer Telkom SA

          L Offline
          L Offline
          Le centriste
          wrote on last edited by
          #4

          I would check for nullity of either mail.Subject or filter.

          ----- Formerly MP(2) If atheism is a religion, then not collecting stamps is a hobby. -- Unknown

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups