Gandalf
Member
Hi, I am able to add worksheet ranges and Sheet names to an Outlook email body. Is there any way of inserting a range of addresses from a worksheet into the recipient (.To) field? The addresses are in another Worksheet (not the ActiveSheet) called "Volunteers" range D2:D40
Code:
Private Sub CommandButton1_Click()
'
' EmailCopy Macro
Dim rng As Range
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Set rng = Nothing
On Error Resume Next
Set rng = ActiveSheet.Range("A1:N34").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
' CREATE EMAIL OBJECT.
Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = "Enter email recipient addresses "
.Subject = " Volunteer schedule for " & ActiveSheet.Name
.HTMLBody = RangetoHTML(rng)
.Display ' DISPLAY MESSAGE.
End With
' CLEAR
Set objEmail = Nothing:
Set objOutlook = Nothing
End Sub