0

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.

1
  • TLDR - Works for me, except for security settings. I added a reference to "Microsoft Outlook 16.0 Object Library" and it automatically added two additional references, "Microsoft Office 16.0 Object Library" and "OLE Automation". Your example code worked fine for me, except that 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. Commented Oct 24 at 18:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.