Wednesday, November 2, 2011

SendMail Method in VBA

The SendMail Method is very easy to use and will send any specified Excel Workbook as an attachment to specified recipients.

As the code below specifies the Active Workbook the code is best stored in your Personal.xls

Sub SendActiveWorkbook()

ActiveWorkbook.SendMail _

Recipients:="chithu.palaniappan@gmail.com", _

Subject:="Try Me " & Format(Date, "dd/mmm/yy")

End Sub

If you only wish to send one Worksheet from a Workbook we can use the method shown below. It creates a new Workbook housing

ONLY the sheet we copy. It then sends the 1 sheet Workbook as an attachment, then closes the new Workbook without saving.

No comments: