Good morning. I have this code that creates an Outlook email message based on data from my Sheet and sends to the person I select. Now I'm wondering if it's possible to format the body of the message...
VBA Code:
Sub SendPlanRequestUpdateEmail()
Call FloorPlanRequests
Dim Ans As VbMsgBoxResult
Ans = MsgBox("Are you sure you want to Send a Floor Plan Request Update?", vbYesNo + vbQuestion)
If Ans = vbNo Then Exit Sub
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Sheets("FloorPlanRequests").Visible = True
Sheets("FloorPlanRequests").Select
ActiveSheet.Unprotect
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Set rng = Nothing
On Error Resume Next
Set rng = Selection.SpecialCells(xlCellTypeVisible)
Set rng = Sheets("FloorPlanRequests").Range("FloorPlanRequests").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Settings.DesignerEmailReturn.Value
.CC = Settings.CCNames.Value
.Subject = "Floor Plan Request Update for " & Format(Now, "m/dd/yy")
.HTMLBody = "In order of priority:" & "<br>" & RangetoHTML(rng) & "<br>" & "Thanks!"
.Send
End With
On Error GoTo 0
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("FloorPlanRequests").Visible = False
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
Sheets("Calendar").Select
End Sub