SunilSunny
New Member
- Joined
- Jul 23, 2020
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
I have created a command button in excel which when clicked opens a new email box. The code is as below.
What I want help is that when the button is clicked it opens the email box and automatically "To" field is filled (which should be picked from one cell of that excel sheet )
Private Sub CommandButton1_Click()
'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "" & vbNewLine & vbNewLine & _
"Regards" & vbNewLine & _
"Sunny"
On Error Resume Next
With xOutMail
.To = ActiveCell
.CC = "someone@xyz.com.au"
.BCC = ""
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
What I want help is that when the button is clicked it opens the email box and automatically "To" field is filled (which should be picked from one cell of that excel sheet )
Private Sub CommandButton1_Click()
'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "" & vbNewLine & vbNewLine & _
"Regards" & vbNewLine & _
"Sunny"
On Error Resume Next
With xOutMail
.To = ActiveCell
.CC = "someone@xyz.com.au"
.BCC = ""
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Last edited by a moderator: