BenGrobler
New Member
- Joined
- Apr 19, 2021
- Messages
- 31
- Office Version
- 2019
- 2016
- Platform
- Windows
Dim xRg As Range
'Update by Extendoffice 2018/3/7
Private Sub Worksheet_Sheet1(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("M6"), Target) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value > 3 Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hi" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Forklift Training"
.Body = "Good day HR & Training Department" & vbNewLine & _
"" & vbNewLine & _
"Please book Forklift training as soon as possible as his current license will expire very soon." & vbNewLine & _
"" & vbNewLine & _
"Best Regards" & vbNewLine & _
"" & vbNewLine & _
"ELF Management"
.display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
HOw do i modify the above code to trigger the vba code?
'Update by Extendoffice 2018/3/7
Private Sub Worksheet_Sheet1(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("M6"), Target) Is Nothing Then
If IsNumeric(Target.Value) And Target.Value > 3 Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hi" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Forklift Training"
.Body = "Good day HR & Training Department" & vbNewLine & _
"" & vbNewLine & _
"Please book Forklift training as soon as possible as his current license will expire very soon." & vbNewLine & _
"" & vbNewLine & _
"Best Regards" & vbNewLine & _
"" & vbNewLine & _
"ELF Management"
.display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
HOw do i modify the above code to trigger the vba code?
Last edited: