Hello Community,
I have an Outlook macro, which creates a new email when a button is clicked. The macro works well if I specify the subject as only one cell. Here it is :
Private Sub CommandButton1_Click()
Dim a As Integer
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngSubject As Range
Dim rngBody As Range
Dim rngAttach As Range
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
a = ActiveCell.Row
With ActiveSheet
'Set rngTo = .Cells(a, "C")
Set rngSubject = .Cells(1, "A")
Set rngBody = .Range("C17:M24")
'Set rngAttach = .Range("B4")
End With
With objMail
'.To = rngTo.Value
.Subject = rngSubject.Value
.Body = rngBody.Value
'.Attachments.Add rngAttach.Value
.Display 'Instead of .Display, you can use .Send to send the email _
or .Save to save a copy in the drafts folder
End With
Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngSubject = Nothing
Set rngBody = Nothing
Set rngAttach = Nothing
End Sub
The problem happens when I set the body range to multiple cells. You see, I have text in C17 and a table in C18:M22. I want to include both the text and the table in the email that pops up.
Any help or up is truly greatly appreciated!
Cheers,
Daniel O.