I am trying to automatically send an email when a certain condition is met. I am close, but can't figure out what I am missing. Everything works fine, until the time I call Email
Below is the code to send the email.
Below is the code to send the email.
VBA Code:
Sub Email()
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.To = "dmrubin25@gmail.com"
.CC = "dmrubin25@gmail.com"
.BCC = "dmrubin25@gmail.com"
.Subject = "ACTION REQUIRED: ENTER A BACKORDER" & CS.Range("G4").Value & "PO Number " & CS.Range("G20")
.BodyFormat = olFormatHTML
.Display
.HTMLBody = "Please create a backorder for the following:" & vbNewLine & vbNewLine & "Customer: " & CS.Range("G4").Value & vbNewLine & _
"Customer #: " & CS.Range("M4").Value & vbNewLine & "Quantity: " & CS.Range("R8").Value & vbNewLine & "PO Number: " & CS.Range("G20").Value & _
vbNewLine & vbNewLine & "Contact for Questions: " & CS.Range("M14").Value
.Importance = 2
.Send
End With
SetoutlookMail = Nothing
Set OutlookApp = Nothing
End Sub