choose which email message to send

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
672
Office Version
  1. 365
Platform
  1. Windows
i have an email set up once a check number is filled in see code below
this works well if all the fields are filled in.
is there a way to do an if statement
if Cells(Target.Row, "AB").Value <> blank then an entirely different email needs to be sent, that means override the previous send email based on column 17

Private Sub Macro2(ByVal Target As Range)

If Target.Column = 17 And Target.Cells.Count = 1 Then

If Target.Value <> "" Then


result = MsgBox("pressing OK will send email to notify", vbOKCancel + vbExclamation, "Missing Approval")

If result = vbCancel Then SaveUI = True

If result = vbOK Then


Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)

On Error Resume Next

newmsg.Recipients.Add (Cells(Target.Row, "Z").Value) ' Add Recipients
newmsg.Recipients.Add (Cells(Target.Row, "AA").Value)
newmsg.Subject = Cells(Target.Row, "B").Value & " Reimbursement" ' Add Subject
newmsg.Body = "This is to inform you that payment has been processed " & _
"on behalf of " & Cells(Target.Row, "B").Value & "." & vbCrLf & "" & _
"Check # " & Cells(Target.Row, "P").Value & " was issued " & " for the amount of " & "$" & Cells(Target.Row, "Q").Value & _
" for services in the month of " & Cells(Target.Row, "C").Value & " for " & Cells(Target.Row, "F").Value & Cells(Target.Row, "G").Value & ", " & "(" & "billed amount " & "$" & Cells(Target.Row, "K").Value & ")." & vbCrLf & "" & _
"(If Check amount is greater than billed amount, this check contains multiple receipts and reimbursement requests.)"
newmsg.Send 'Send Email
newmsg.PrintOut


End If
End If
End If

End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,213,533
Messages
6,114,179
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top