How to Send Emails Using VBA in MS Excel

This guide will show you how to send emails directly from Microsoft Excel using Visual Basic for Applications (VBA).

Step 1: Enable Developer Tab in Excel

  • Go to ‘File’ > ‘Options’ > ‘Customize Ribbon’.
  • Check the ‘Developer’ checkbox and click ‘OK’.

Step 2: Access VBA Editor

  • Press Alt + F11 to open the VBA Editor.

Step 3: Insert a New Module

  • In the VBA Editor, right-click on ‘VBAProject (YourWorkbookName.xlsm)’ > ‘Insert’ > ‘Module’.

Step 4: VBA Code to Send Email

  • Copy and paste the following VBA code into the module:

Sub SendEmail()
    Dim OutlookApp As Object
    Dim OutlookMail As Object
    Set OutlookApp = CreateObject("Outlook.Application")
    Set OutlookMail = OutlookApp.CreateItem(0)

    With OutlookMail
        .To = "[email protected]"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject Line"
        .Body = "Write your email body here."
        .Attachments.Add ("C:\\path\\to\\your\\file.pdf") ' Optional
        .Send
    End With

    Set OutlookMail = Nothing
    Set OutlookApp = Nothing
End Sub


Step 5: Run the VBA Script

  • Close the VBA Editor and return to Excel.
  • Press Alt + F8, select ‘SendEmail’, and click ‘Run’.

Note: Ensure Microsoft Outlook is installed on your computer and properly set up with your email account. This script uses Outlook to send the email.

Additional Tips:

  • Modify the .To, .CC, .BCC, .Subject, and .Body fields as needed for your email.
  • If you don’t need to attach a file, remove or comment out the .Attachments line.

Artificial Intelligence Generated Content

Welcome to Ourtaxpartner.com, where the future of content creation meets the present. Embracing the advances of artificial intelligence, we now feature articles crafted by state-of-the-art AI models, ensuring rapid, diverse, and comprehensive insights. While AI begins the content creation process, human oversight guarantees its relevance and quality. Every AI-generated article is transparently marked, blending the best of technology with the trusted human touch that our readers value.   Disclaimer for AI-Generated Content on Ourtaxpartner.com : The content marked as "AI-Generated" on Ourtaxpartner.com is produced using advanced artificial intelligence models. While we strive to ensure the accuracy and relevance of this content, it may not always reflect the nuances and judgment of human-authored articles. [Your Website Name] and its team do not guarantee the completeness or reliability of AI-generated content and advise readers to use it as a supplementary resource. We encourage feedback and will continue to refine the integration of AI to better serve our readership.

Leave a Reply

Your email address will not be published. Required fields are marked *