Adding code to a command button

T

Todd

I am trying to add the following code to a command button
so it will run when the button is pressed. I created the
command button then inserted the code under the "Private
Sub CommanButton1_click () phrase. It returns a compile
error message of "Expected End Sub" when it is run. Is
the wording incorrect on this or is there another
problem? Thanks for the help. The code is below:

Private Sub CommandButton1_Click()
Sub Mail_workbook_Outlook()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

End Sub
 
J

JulieD

Hi Todd

haven't really read through each line of your code but removing
Sub Mail_workbook_Outlook()
and one of the
End Sub
lines
might be a starting point.

Cheers
JulieD
 
Top