Results 1 to 4 of 4

Thread: VBA to Send Email Using NEW Outlook

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA to Send Email Using NEW Outlook

    Hello,

    I have now switched to the New Outlook, but the VBA code I use for sending emails to people appears not to work. I have been looking into this for weeks now and can't find a solution. Does anyone know how to fix this please?

    Please see my VBA code below.

    Thanks in advance. Kind regards,

    Johno

    Dim EmailAddr As String, OutApp As Object, OutMail As Object, strbody As String
    Dim WSHnet As Object
    Dim OL As Object, olAllUsers As Object, oExchUser As Object, oentry As Object, User As String
    Set WSHnet = CreateObject("WScript.Network")
    Set OL = CreateObject("outlook.application")
    Set olAllUsers = OL.Session.AddressLists.Item("All Users").AddressEntries
    User = OL.Session.CurrentUser.Name
    Set oentry = olAllUsers.Item(User)
    Set oExchUser = oentry.GetExchangeUser()
    EmailAddr = ""
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    strbody = "Hello. This is my email. " & vbNewLine & vbNewLine & _
     "Regards," & vbNewLine & vbNewLine & _
    "Me"
    With OutMail
    EmailAddr = 'myemailaddress'
    .To = EmailAddr
    .Subject = " Example Email"
    .Body = strbody
    .Send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    Load CloseCheck
    CloseCheck.Show
    End Sub
    Last edited by Aussiebear; 10-11-2023 at 12:54 PM. Reason: Added code tags to supplied code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •