SendMail Method of Workbook Object VBA

SendMail Workbook method is used to sends the workbook via an email as an attachment by using the installed mail system.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates


When we use SendMail Workbook Method in VBA?

We use SendMail workbook method when we wanted to send an email to the specified recipients and workbook as an attachment. We can also send particular worksheet as workbook.

VBA SendMail Workbook Method- Syntax

Here is the syntax of SendMail workbook method in VBA.

Workbooks(“Your Workbook Name”).SendMail(Recipients,

[Subject], [ReturnReceipt])

Where,
Recipients: It is required parameter. It specifies the name of the recipient(s) and added as To recipients.
Subject: It is an Optional parameter. It specifies the subject of the message. If you don’t specify any name, Default name is document name.
ReturnReceipt: It is an Optional parameter. Default value is False. If it is True notifies the sender when recipient receives an email.

VBA SendMail Workbook Method: Example 1

Please find the below example, it will show you how to send an email using SendMail workbook method using VBA.

Sub End_Email()
ThisWorkbook.SendMail "", "Sample Workbook"
End Sub

Explanation:In the above example it will send the activeworkbook as an attachment to and subject is ‘Sample Workbook’.

VBA SendMail Workbook Method: Example 2

Please find the one more example, it will send one worksheet from a workbook.

Sub Send_Worksheet()
ThisWorkbook.Sheets(“Sheet1”).Copy
With ActiveWorkbook
.SendMail Recipients:="", Subject:="Sample Workbook"
.Close SaveChanges:=False
End With
End Sub

Explanation: It will create a new workbook with which we are copying worksheet and send as an attachment. And then finally it closes the new workbook which we created without saving.

VBA SendMail Workbook Method – Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Workbook
  2. Press Alt+F11 to Open VBA Editor
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating a range and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled workbook
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line.
LIMITED TIME OFFER

Leave A Comment


Related pages


sql objective type questions and answers pdfexcel macro delete blank rowshide multiple columns in excelexcel 2003 pivot table tutorialvba startvb coding examplesisna excel formulacreate text file vbaunprotect sheet command exceldrop down macro excelworksheet and workbookinteractive excel chartunhide all rows excelvba end loopexcel vba for each cell in rangetest automation interview questions and answersbar of pie excelvba import data from another workbookvba oopmicrosoft excel template downloadsaptitude and technical test questions and answersexcel macro tutorialvba torrentexcel vba sumifuserform in vbaactivecell addressexcel dashboard creationhow to combine multiple cells in excelifs in excelvb calculatorunderstanding excel macrossimple excel macro tutorialado odbc connection stringdelete empty cells exceltimevalue excelexcel sumif commandsql query examples with answers pdfexcel 2007 offsetexcel find duplicatesvba open a text filecountif function on excelhow to unprotect excel 2010how to make a 100 stacked bar chart in excelvba rgb colortutorial excel macrosstring vbascheduler template excelvba open access database from excelexcel vba listboxunprotect workbook excel 2013excel consolidation tutorialswot analysis template powerpointexcel pivot table referenceexcel worksheet hiddensheets in vbaproject tracking with excelhow to do hlookup in excelexcel formula for vlookuptechnical interview questions for freshers with answers pdfvba export excel to accesshow to delete duplicate records in excel 2007save excel vbavba columnvba application.enableeventsexcel dashboard add inshow to create pivot chart in excel 2007select sheet vbavba excel switchexcel vba open files in foldersql data manipulation commandslearn macros in excel 2007macros basicswriting excel macrosexcel project management templateunprotecting excelvba sql statementexcel macro close excelwhat is workbook and worksheetproject plan template excelexcel password protected file forgot passwordhide worksheets in excelexcel template for timelineexcel lock sheetwhat are dashboards in excelvbyesno in vbaexample of vlookup in excel 2010