Excel Macro to send Outlook Email

bthumble

Board Regular
Joined
Dec 18, 2007
Messages
231
Hello,

I have created a macro to send email from my excel spreadsheet. But need help with adding more than one line for the body. Below is my code, but I need the macro to copy the body from C7-C13 (total of seven lines). Have attempted to do a range such as C7-C13 or C7,C13 but no success. Thanks for your help.

Sub send_email()

Dim OutApp As Object
Dim Outmail As Object
Set OutApp = CreateObject("Outlook.Application")
Set Outmail = OutApp.CreateItem(0)

With Outmail
.To = Range("C3").Value
.Subject = Range("C5").Value
.Body = Range("C7").Value

.display
End With

Set Outmail = Nothing
Set OutApp = Nothing

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Note: Only works if you have Office 365

VBA Code:
.Body = Application.WorksheetFunction.TextJoin(vbNewLine, True, Range("C17:C13").Value)
 
Upvote 0
Thank you for the reply. But when I did this, it only brings in the very last line of the range. Not sure if I am doing something incorrectly.
It looks like there was a typo in Jan's response.

This part:
Rich (BB code):
Range("C17:C13")
should have been:
Rich (BB code):
Range("C7:C13")
 
Upvote 0
change the Range portion to:

Rich (BB code):
Range("C7:C13").Value)
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top