none
Issues with Excel 2016 VBA to send emails RRS feed

  • Question

  • Hi we recently at work moved from 2010 to Office 365 (Office 2016).  Now my macro's with VBA coding will no longer send emails.  What is wrong that is causing it to stop?  What coding do I need to change?

         ' Emails the Outlook Insurance group code letting them know the file is ready for review
              Dim OutApp As Object
              Dim OutMail As Object
              Const SendTo As String = "your email address"

              Set OutApp = CreateObject("Outlook.Application")

              OutApp.Session.Logon
              Set OutMail = OutApp.CreateItem(0)

              With OutMail
                 .To = Donald duck  (please note I removed my emails addresses I normally use)
                 .Subject = ActiveWorkbook.Name & " " & "report is ready for initial opp letters"
                 .body = "The PP" & " " & FName & " " & "Comp NOA report is now available. " _
                  & vbNewLine & vbNewLine & _
                  "<\\VP0SENTSHRCMN03\Common2\PPS\PP\ODN\BRANCH\Insurance Unit\Reports\Reports>"
                 .Send
             End With

             Set OutMail = Nothing
             Set OutApp = Nothing

         ' Display Msg Box
            MsgBox ("CompNOA_Macro2 has completed.") _
            & vbNewLine & vbNewLine & _
            "Click OK to close this message box."

         End Sub

    When I test line by line, this debugs at the .Send

    Thank you for any help

    • Edited by SPewtress Thursday, December 7, 2017 4:57 PM updated missed code
    Thursday, December 7, 2017 4:55 PM

All replies

  • Hi SPewtress,

    I failed to reproduce your issue. I would use your code to send a mail in Office 2016.

    You said that you debugs at the .Send. What's the error? Did you get any error message? If you try to use .Display to show the mail, will you see the correct mail in inspector?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 8, 2017 1:30 AM
  • Just to confirm that I get this same issue when moving from office 2010 to office 2016

    I will continue looking for a solution

    Friday, October 26, 2018 2:37 PM