How to Send Email Using Excel 2007 VBA

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Send Email Using Excel 2007 VBA
Send e-mail from Excel using VBA. (E-mail Concept image by wayne ruston from Fotolia.com)

Visual Basic for Applications (VBA) is commonly used to automate routine tasks in Microsoft Office applications. Sending an e-mail from Microsoft Excel 2007 using VBA is useful in cases when you need to continuously e-mail the latest data in an Excel workbook. In a few steps you can write code to easily automate the task of sending the email through Microsoft Outlook.

Skill level:
Easy

Other People Are Reading

Instructions

  1. 1

    Start Microsoft Office 2007 and select the "Developer" tab. Click on "Visual Basic" and select "Tools." Click on "References" check "Microsoft Outlook 12.0 Object Library" and select "OK."

  2. 2

    Type the following to create a new sub:

    Sub sendEmail()

    Press "Enter."

  3. 3

    Type the following to create your variables:

    Dim oLookApp As Outlook.Application

    Dim oLookMail As Outlook.MailItem

  4. 4

    Type the following to assign the outlook object and create a new e-mail:

    Set oLookApp = New Outlook.Application

    Set oLookMail = oLookApp.CreateItem(0)

  5. 5

    Type the following to define the variables for your e-mail:

    With oLookMail

    .To = "john.doe@yahoo.com"

    .Subject = "My Workbook"

    .Body = "I'm e-mailing this workbook.."

    .Attachments.Add ActiveWorkbook.FullName

    .send

    End With

  6. 6

    Execute your sub to e-mail the current Excel workbook.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.