vbalearner721
New Member
- Joined
- Apr 27, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Here below is the code to create a draft email from excel, the current region is correctly selected but it doesn't show in email body correctly, it only shows a word "True", please see attached 2 pics.
Please help as I have googled for days and cannot sort out the problem, thank you so much.
Dim myDataRng As Range
Set myDataRng = Range("c2:c2")
Dim hk As String
hk = 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 = "shipping@therange.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>" & _
hk & "<br>" & "<br>"
.Save
End With
Please help as I have googled for days and cannot sort out the problem, thank you so much.
Dim myDataRng As Range
Set myDataRng = Range("c2:c2")
Dim hk As String
hk = 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 = "shipping@therange.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>" & _
hk & "<br>" & "<br>"
.Save
End With