• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sending Emails via Outlook using Excel VBA

Badriah

New Member
Hi everyone,

I'm trying to send a simple email from Excel using VBA. I'm using the following macro on a Windows system with Outlook installed:


Code:
Sub SendSimpleEmail()
    Dim OutApp As Object
    Dim OutMail As Object


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)


    With OutMail
        .To = "example@example.com"
        .Subject = "Test Email"
        .Body = "This is a test email from Excel VBA."
        .Display
    End With
End Sub


Here are my questions:

  1. What is the purpose of CreateObject("Outlook.Application")?
  2. How can I attach the current workbook automatically to this email?
  3. Is there any way to make this kind of email macro work on a Mac?
Thanks in advance for your guidance!
 
Hi, as CreateObject statement is specific to Windows to link the Outlook application it can not work on Mac, like explained in VBA help …​
 
Your macro works with the OLD VERSION MS Outlook. If you are using the NEW VERSION of Outlook you are out of luck.
MS changed the new version so it no longer supports sending email via VBA Excel.
 
MS changed the new version so it no longer supports sending email via VBA Excel.
As I remember it never did in MS outlook (old or new) MS outlook is not office outlook.
I work with office 365 an have about 20 different mail codes (including send workbook as attachment) that still are working.
But Marc L is right it will not work on a Mac.
 
Back
Top