Hi
I found the following example at
http://www.rondebruin.nl/win/s1/outlook/bmail2.htm
on how to email an Excel range using the mail envelope in Excel VBA.
I need to email two separate ranges one under the other eg C16:D17 and C136:D165
How would I do this?
Note: The worksheet/range not have to be active when you run the code.
Sub Send_Range_Or_Whole_Worksh
eet_with_M
ailEnvelop
e()
'Working in Excel 2002-2013
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Fill in the Worksheet/range you want to mail
'Note: if you use one cell it will send the whole worksheet
Set Sendrng = Worksheets("Sheet1").Range
("A1:B15")
'Remember the activesheet
Set AWorksheet = ActiveSheet
With Sendrng
' Select the worksheet with the range you want to send
.Parent.Select
'Remember the ActiveCell on that worksheet
Set rng = ActiveCell
'Select the range you want to mail
.Select
' Create the mail and send it
ActiveWorkbook.EnvelopeVis
ible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "This is test mail 2."
With .Item
.To = "ron@debruin.nl"
.CC = ""
.BCC = ""
.Subject = "My subject"
.Send
End With
End With
'select the original ActiveCell
rng.Select
End With
'Activate the sheet that was active before you run the macro
AWorksheet.Select
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVis
ible = False
End Sub