lesley burlingham
Member
Hi
I would like to have a button on my form which opens a new email message - I want the destination name populated and the subject to have details from the spreadsheet.
I don't want the email to send automatically.
I have the following.
I would like to have a button on my form which opens a new email message - I want the destination name populated and the subject to have details from the spreadsheet.
I don't want the email to send automatically.
I have the following.
Code:
Sub SendMeFromExcel()
Dim EmailTo As String
Dim oApp As Object
Dim oItem As Object
On Error GoTo ErrorHandler
EmailTo = "lesley-ann.burlingham@cnhind.com"
Set oApp = CreateObject("Outlook.Application")
Set oItem = oApp.CreateItem(0)
With oItem
.To = EmailTo
.Subject = "This is a test. This email is being sent from Excel!!!"
.Body = "You can put the body too"
.Importance = 1
.Send
End With
GoTo ExitSub
ErrorHandler:
MsgBox "There was an error."
ExitSub:
Set oItem = Nothing
Set oApp = Nothing
End Sub