How to do mail from excel

You can send an email from Excel using VBA (Visual Basic for Applications) programming. Here's a step-by-step guide:

Prerequisites:

  1. You need to have Excel 2007 or later version.
  2. You need to have Outlook installed on your computer.

Step 1: Enable the Developer Tab

  1. Go to the "File" menu and click on "Options".
  2. In the "Excel Options" window, click on the "Customize Ribbon" button.
  3. Check the box next to "Developer" and click "OK".

Step 2: Create a Macro

  1. Go to the "Developer" tab and click on the "Visual Basic" button.

  2. In the Visual Basic Editor, click on "Insert" > "Module" to insert a new module.

  3. Paste the following code into the module:

    Sub SendEmail()
     Dim olApp As Object
     Dim olMail As Object
    
     Set olApp = CreateObject("Outlook.Application")
     Set olMail = olApp.CreateItem(0)
    
     With olMail
        .To = "[email protected]"
        .Subject = "Test Email from Excel"
        .Body = "This is a test email sent from Excel using VBA."
        .Send
     End With
    
     Set olMail = Nothing
     Set olApp = Nothing
    End Sub

    Step 3: Run the Macro

  4. Go back to the Excel worksheet.

  5. Press "Alt + F8" to open the Macro dialog box.

  6. Select the "SendEmail" macro and click "Run".

Step 4: Configure the Email Settings

  1. In the code, you need to replace "[email protected]" with the actual email address you want to send the email to.
  2. You can also modify the subject and body of the email as needed.

Tips and Variations:

Security Note: