This project has moved. For the latest updates, please go here.

Visual Studio Outlook Project References

Jan 19 at 9:06 PM
Edited Jan 19 at 10:18 PM
Hi,

I am trying to develop a simple outlook project to get some basic knowledge on how NetOffice is used. I am using vb.net in the Visual Studio Community IDE. I have Office 365 installed. I have created references to the NetOffice.dll, OutlookAPI.dll, OfficeAPI and VBIDEApi.dll. I have not referenced the Outlook 16 object library (Office 365). My code, which was copied from one of the examples is:

Imports NetOffice.OutlookApi
Imports NetOffice.OutlookApi.Enums

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    ' send mail in outlook
    ' taken from Example03.vb
    ' start outlook
    Dim outlookApplication = New Outlook.Application()

    ' Create a new MailItem.
    Dim mailItem As Outlook.MailItem = outlookApplication.CreateItem(OlItemType.olMailItem)

    ' prepare item and send
    mailItem.Recipients.Add("xx@xx.com")
    mailItem.Subject = "hello eric"
    mailItem.Body = "Season Greetings from NetOffice. Kind Regards - Sebastian"
    mailItem.Send()

    ' close outlook and dispose
    outlookApplication.Quit()
    outlookApplication.Dispose()


End Sub
End Class


The issue that I have is that is that types Outlook.Application() and Outlook.MailItem are not defined. I can fix that by adding a reference to the Outlook 16 object library and Importing Microsoft.Office.Interop but my understanding was that this is not supposed to be required. Is that correct? It appears that I have missed something. If anyone can point me in the right direction it would be appreciated.

Thanks
Jan 21 at 1:26 AM
Hi,

Eventually I solved my issue by setting the Embed Interop Types property for the NetOffice references to false.

Thanks
Coordinator
Jan 24 at 5:53 AM
You need set any NetOffice reference option "Embed Interop Types" to false.

Visual Studio do a mistake here and set this option true by default because NetOffice assemblies mask himself as an PIA Interop Assembly.


*Sebastian