here is a copy of my VBA
Private Sub VerbalWarning_Click()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Open a new e-mail message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = 'send to this address
.CC = [GroupEmail]
.BCC = "XXXXXX Removed for Security resons XXXXXX"
.Subject = [FullName] & " - " & "VERBAL WARNING" 'This is the message subject
.Body = "Good Day,"
" "
"Please let this Email serve as a verbal warning"' This is the message body text
.Display
End With
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Private Sub VerbalWarning_Click()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Open a new e-mail message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = 'send to this address
.CC = [GroupEmail]
.BCC = "XXXXXX Removed for Security resons XXXXXX"
.Subject = [FullName] & " - " & "VERBAL WARNING" 'This is the message subject
.Body = "Good Day,"
" "
"Please let this Email serve as a verbal warning"' This is the message body text
.Display
End With
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Last edited: