Trying to insert range as body of email

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
83
Trying to write macro that will create an email object with a range of cells as the body. Ultimately I will probably set a cell as the "To" address, but for now I just wanted to get the mail object created with the contents from the page.

Code:
Sub CreateDocLlistMail()


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)






With Sheets("Publish Doc List")
    'Set rngTo = .Cells(a, "C")
    'Set rngSubject = .Cells(a, "E")
     Set rngBody = .Range("B1:D28")
    '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

Any advice is greatly appreciated.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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