aprajitaj's blog

E-mail the contents of your Excel file using VBA

The below code mails a range of 20 cells, A1 through B10, from the currently active workbook to the e-mail address specified in the code:

Sub EmailRange()

' Select the range of cells on the active worksheet.
ActiveSheet.Range("A1:B10").Select

' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True

' Set the optional introduction field thats adds
' some header text to the email body. It also sets
' the To and Subject lines. Finally the message
' is sent.
With ActiveSheet.MailEnvelope

Syndicate content