How to send email from VB 2015 using Outlook?

I am trying to send e-mail from a 2015 VB app and am having trouble.  I have basically copied code from the MSDN web site for VB 2013 and later.  I could not find 2015 specific code.

The problem I have is  .CreateItem nor .Session are members of Application.  I fell like I have left something out, but not sure what.

I have added as references Microsoft Office 10. Object Library and Microsoft Outlook 15.0 Object Library.
I have included the import in my project.
   Imports Outlook = Microsoft.Office.Interop.Outlook



    
Private Sub SendSalesReport()
        Dim mail As Outlook.MailItem = CType(Application.CreateItem(
            Outlook.OlItemType.olMailItem), Outlook.MailItem)
        mail.Subject = "Quarterly Sales Report FY06 Q4"
        Dim currentUser As Outlook.AddressEntry =
            Application.Session.CurrentUser.AddressEntry
        If currentUser.Type = "EX" Then
            Dim manager As Outlook.ExchangeUser =
                currentUser.GetExchangeUser().GetExchangeUserManager()
            ' Add recipient using display name, alias, or smtp address
            mail.Recipients.Add(manager.PrimarySmtpAddress)
            mail.Recipients.ResolveAll()
            mail.Send()
        End If
    End Sub

Open in new window

JeffMCCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
0
Najam UddinCommented:
Try changing Application to Outlook.Application
0
JeffMCCAuthor Commented:
@Najam,

I tried changing to Outlook.Application.  I now get Reference to non-shared member requires an object reference.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

JeffMCCAuthor Commented:
@Eric,

I'll take a look at that, but was hoping to get this method working.

Thanks
0
Najam UddinCommented:
That issue that solved by making
Private Sub SendSalesReport() 

Open in new window

to
Public Shared Sub SendSalesReport()

Open in new window

0
ktaczalaCommented:
add: Dim AppOutlook as New Outlook.Application
then change your 2 lines of code to this:
Dim mail As Outlook.MailItem = CType(AppOutlook .CreateItem(
            Outlook.OlItemType.olMailItem), Outlook.MailItem)

Dim currentUser As Outlook.AddressEntry =
            AppOutlook .Session.CurrentUser.AddressEntry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JeffMCCAuthor Commented:
@Najam,

That still did not work.  Same message.

@ktaczala,

That worked.  Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.