Below is code that works fine for sending an entire workbook to an Outlook email recipient using Excel VBA. I want to know how to modify this code so that I can send a single worksheet (not the whole workbook, and not necessarily the active worksheet) to an Outlook email recipient.
Thanks for your help!
Glenn
______________________________
Sub Send_Email()
Dim outlookApp As Object
Dim outlookMail As Object
Set outlookApp = CreateObject("Outlook.Application")
Set outlookMail = outlookApp.CreateItem(0)
With outlookMail
.To = "recipient@yourco.com"
.Subject = "Test email File"
.BodyFormat = 2
.HTMLBody = "Hi,<p>This is a test email from Excel using VBA."
.Attachments.Add ActiveWorkbook.FullName
.Importance = olImportanceHigh
.Send
End With
Set outlookMail = Nothing
Set outlookApp = Nothing
End Sub
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.