tbrynard01
Board Regular
- Joined
- Sep 20, 2017
- Messages
- 131
- Office Version
- 365
- Platform
- Windows
I have the following code in a button and would like to add the code to check for required fields on the spreadsheet before it sends the email and to not send unless all the required fields are required, but not sure where to put it in this code - Thank you!:
VBA Code:
Sub Email2()
' Keyboard Shortcut: Ctrl+Shift+S
'
Range("A3").Select
Selection.End(xlDown).Select
ActiveWorkbook.Save
Dim outlook As Object
Dim newEmail As Object
Dim xInspect As Object
Dim pageEditor As Object
Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)
With newEmail
.To = Sheet8.Range("B21").Text
.CC = Sheet8.Range("G21").Text
.BCC = ""
.Subject = "MHR Request"
.Body = ""
.display
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor
Sheet8.Range("A1:F20").Copy
pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)
.display
.Send
Set pageEditor = Nothing
End With
Set newEmail = Nothing
Set outlook = Nothing
Call ClearForm
End Sub