1

I have taken over development of a VB .NET 3.5 project. I need to add a reference to Microsoft.Office.Interop.Outlook for Office 2013, but it doesn't appear in my COM Reference list. I have Office 2013 installed. I have tried to find an installer for the PIAs, but I have not been able to find it for 2013.

enter image description here

Any suggestions?

UPDATE

I have upgraded to .NET 4, but I am not able to find the "Microsoft Outlook 15.0 Object Library" in my references (see above image). I tried installing them from the Office disk, but programability was already installed. I also installed the Office Developer Tools from the VS disk. I am at a loss on where to get this file from.

I tried switching to late binding with the following code:

Sub DisplayMail()
    Dim oAPP As Object
    Dim oItem As Object
    Const olMailItem As Long = 0

    oAPP = CreateObject("Outlook.Application")
    oItem = oAPP.CreateItem(olMailItem)
    With oItem
        .To = Me.EmailAddress
        .Subject = Me.MySubjectTextBox.Text.Trim.Replace("%", "%25").Replace("&", "%26")
        .Body = Me.EmailMessageBox.Text.Trim.Replace("%", "%25").Replace(vbCr, "%0d%0A").Replace("&", "%26")
        .Display()
    End With
End Sub

This works when Outlook is closed, but if I have Outlook open, I get a "Cannot create ActiveX component" error.

Tim
  • 2,731
  • 9
  • 35
  • 72
  • 1
    There is no PIA anymore for Office 2013, they are obsolete since the "Embed Interop Types" feature added in .NET 4 + VS2010. You need to select "Microsoft Outlook 15.0 Object Library" from the COM tab. – Hans Passant Mar 10 '15 at 16:12
  • @HansPassant: Thank you for your response. My project is in .NET 3.5, and my supervisor would prefer that I don't change it. Before making the argument, I want to confirm that upgrading to .NET 4 and using Microsoft 15.0 Object Library is the best way to proceed. Again, thank you for your response. – Tim Mar 10 '15 at 16:30
  • Getting stuck on an 8 year old version of free software is a problem that you cannot get help with here. [Maybe here](http://careers.stackoverflow.com/). – Hans Passant Mar 10 '15 at 16:33
  • @Tim it might be worth pointing out to your supervisor that .Net 3.5 (released 2007-11-19) predates office 2013 (2013-01-29) by more than 5 years – 5uperdan Mar 10 '15 at 16:45

1 Answers1

0

If you are working with Late Binding, and your application and Outlook are running under different access levels, you will get the "Cannot create ActiveX component" error.

In my case, Visual Studio was being run as Administrator, while Outlook was being run normally. I closed Outlook and opened it again as Administrator and there were no exceptions.

Tim
  • 2,731
  • 9
  • 35
  • 72