ReignEternal
New Member
- Joined
- Apr 11, 2021
- Messages
- 41
- Office Version
- 365
- Platform
- Windows
Hello,
I have looked through a few of the other threads for this but I have a command button that i want to display an email once the button is clicked. I kep getting an error that says variable not defined. Also in the second image, the two regions of vba keep getting highighted. Overall i am looking to have someone click the "Send Email" button and have it the display hte email and attach the source file path
I have looked through a few of the other threads for this but I have a command button that i want to display an email once the button is clicked. I kep getting an error that says variable not defined. Also in the second image, the two regions of vba keep getting highighted. Overall i am looking to have someone click the "Send Email" button and have it the display hte email and attach the source file path
VBA Code:
Private Sub cmdEmail_Click()
On Error GoTo ErrHandler
' SET Outlook APPLICATION OBJECT.
Dim olApp As Object
Set olApp = CreateObject("Outlook.Application")
' CREATE EMAIL OBJECT.
Dim olEmail As Object
Set olEmail = olApp.CreateItem(olMailItem)
With olEmail
.to = "emailaddresswilllivehere"
.Subject = "This is the Subject of the E-mail"
.Body = "This is the Body of the E-mail"
.Display ' Display the message in Outlook.
.Attachments.Add Source
Source = ThisWorkbook.FullName
End With
' CLEAR.
Set olEmail = Nothing: Set olApp = Nothing
ErrHandler:
'
End Sub