unable to show the extracted region from excel to email html body

vbalearner721

New Member
Joined
Apr 27, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hiya, my code is below but it maybe not good, the main problem is the range("B11").CurrentRegion.Select cannot be shown in the email body, what's wrong with my code??? All the other part can be shown correctly except this range ---> data = Range("B11").CurrentRegion.Select

That''s only a word 'True' show for this part, please point out what's wrong, thank you very much.


Sub Draft()

Dim myDataRng As Range
Set myDataRng = Range("c2:c2")


Dim data As String
data = Range("B11").CurrentRegion.Select

For Each Cell In myDataRng

If Cell.Value > 0 Then

Dim objOutlook As Object
Set objOutlook = CreateObject("outlook.application")

Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)

Range("K2").Select

With objEmail
.SentOnBehalfOfName = "accounting@test.co.uk"
.to = ActiveCell.Offset(0, 1).Value
.Subject = ActiveCell.Offset(7, 0).Value
.htmlbody = "Supplier Code " & " " & Cell.Offset(0, 0).Value & "<br>" & _
"Supplier Name: " & " " & Cell.Offset(1, 0).Value & "<br>" & _
"Currency " & " " & Cell.Offset(2, 0).Value & "<br>" & "<br>" & "Dear Supplier," & "<br>" & "<br>" & _
"A payment has been issued to you, as detailed below. " & "<br>" & _
data & "<br>" & "<br>" & _
"Kind Regards, <br>Johnny Grif <br>Accounts Assistant/Accounts Department" & _
"<br>" & "T:+44(0)1234 567 890" & "<br>" & "E:accounting@test.co.uk"
.Save
End With

Set objOutlook = Nothing

End If

Next Cell

Set myDataRng = Nothing

Set objEmail = Nothing: Set objOutlook = Nothing

MsgBox "Please check pyament advice in your draft folder!"

End Sub


The final outcome is like this>>>>>>>>>>>

Dear Supplier,

A payment has been issued to you, as detailed below.
True

....
..
Kind Regards,
Johnny Grif
Accounts Assistant/Accounts Department
T:+44(0)1234 567 890
E:accounting@test.co.uk
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

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