I'm attempting to send an email template from Excel to Outlook based on the active cell on which the user is selected when clicking the Control button. I've been around and around Ron de Bruin's website testing different scenarios and none seem to fit what I'm looking for.
Let's say I have columns A, B, and C; each column has its own associated email template/text. No matter what row is active in those 3 columns, I want the associated email to be displayed in Outlook when clicking a single Control button. The kicker is that the VBA-ignorant user needs to be able to edit the email template. The closest I've come so far is to do a series of Active Cell and Offset commands to refer to a hidden column containing the email text that I've previously pasted. The problem is that the code is pretty messy (see below), the user needs to delete unnecessary carriage returns before sending the email, and worst of all - the text loses its formatting when sent to Outlook.
I'm thinking all these problems might be solved if I could send an embedded Word doc (Insert >Object) as the body of the email. Is this possible? Thanks!
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
signature = OMail.body
With OMail
.To = Cells(ActiveCell.Row, 6) 'this line works fine
.Subject = Cells(4, ActiveCell.Column) 'this line works fine
.body = "Hi " & Cells(ActiveCell.Row, 1) & "," & vbCrLf & vbCrLf & Cells(4, ActiveCell.Column).Offset(, 26) & vbCrLf & Cells(5, ActiveCell.Column).Offset(, 26) & vbCrLf & Cells(6, ActiveCell.Column).Offset(, 26) & vbCrLf & Cells(7, ActiveCell.Column).Offset(, 26) & vbCrLf & Cells(8, ActiveCell.Column).Offset(, 26) & vbCrLf & Cells(9, ActiveCell.Column).Offset(, 26) & vbCrLf & Cells(10, ActiveCell.Column).Offset(, 26) & vbCrLf & signature
'^^this line works but causes extra carriage returns when the VBA-ignorant user edits the template to something shorter than the original template
End With
Set OMail = Nothing
Set OApp = Nothing
Bookmarks