Macro to copy data from excel to outlook

JannetteChristie

Board Regular
Joined
Dec 14, 2015
Messages
130
Office Version
  1. 365
I have the following code, but I am struggling to get the final part done. THe email body is blank and I cannot work out what I am doing wrong.

Sub SendOutEmail()
Dim rng As Range
Dim rngAddress As String
Dim OutApp As Object
Dim OutMail As Object
Dim PNGFile As String
Dim SheetToSend As String
Dim Subject As String
Dim EmailBody As String

Subject = ActiveSheet.Range("EmailSubject")

With Application
.EnableEvents = False
.ScreenUpdating = False
End With


Set rng = Nothing
Set rng = Sheets("Spec Details").Range("ReportLayout")


Call HideBlankRows



Rows("1:99").Hidden = False

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)


On Error Resume Next
With OutMail
.to = "" _
& "sales@dutypoint.com; "
.Subject = Subject

.HTMLBody = "<span style='font-size:10.5pt; font-family:arial' ><br /><br />" _
& "<img src='" & PNGFile & "'<br /><br />" _



.Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With


Hope someone can help.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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