Outlook.Application is not defined. PIA installed and setup correctly.

  • Thread starter Thread starter tony_pez
  • Start date Start date
T

tony_pez

First timer be gentle. I have this code I am trying to put into a
vb.net addin for ol2003. I get the error Outlook.Application and
Outlook.Selection is not declared. I have installed the PIA's and made
sure they are pointing to the GAC. Any ideas would be apreciated.

Imports Extensibility
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop.Outlook

Public Sub SendToSpam()
Dim objOL As Outlook.Application
Dim objSelection As Outlook.Selection
Dim objMsg As Object
Dim objNewMsg As Object
 
Tony,
Change:
Imports Microsoft.Office.Interop.Outlook

To:

Imports Outlook = Microsoft.Office.Interop.Outlook

You were importing Outlook itself, hence you could have used just
Application instead of Outlook.Application... To avoid name conflicts
between System.Windows.Forms.Application & Outlook.Application I normally
use the above namespace alias.

Hope this helps
Jay
 
That worked! thanks a lot.

However, once I built the add-in. and installed it, I get 'not a valid
office add-in' when trying to add it through Outlook. Any ideas?

Using VS.net 2003, and using the office add-in wizard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top