This is my code
Imports Outlook = Microsoft.Office.Interop.Outlook
Private Sub SenEmail_Click(sender As Object, e As EventArgs) Handles SenEmail.Click
Dim olApp As Outlook.Application = New Outlook.Application()
Dim outlookapp As New Outlook.Application()
Dim mail As Outlook.MailItem = outlookapp.CreateItem(Outlook.OlItemType.olMailItem)
mail.Subject = "Subject"
mail.Body = "Body"
mail.To = "[email protected]"
mail.Send()
End Sub
In this Outlook.MailItem I get an error
BC30002: Type 'Outlook.MailItem' is not defined.
And with outlookapp.CreateItem(Outlook.OlItemType.olMailItem), I get
BC30456: CreateItem is not a member of application
I added "Microsoft Outlook 16.0 Object Library" and "Microsoft Outlook View Control" on Reference Manager.
What am I missing?
I just want to know if I'm missing some library or what I'm missing in my code.
mail.Send()will likely fail as it did for me due to security restrictions. However,mail.Save()successfully saved the email in my Drafts folder. By the way, I used .NET Framework 4.8.1, console app.