I am using a code to export any range from excel file and insert ( as table ) on the body of outlook new message.
It works with one issue, that the bottom border is always missing
after inserted on outlook mail body.
Note: If I changed manually the height or width of the table then the bottom border appears normally.
The code is long to post here ,So I will show the part of HTML which I think the problem exists.
As always, grateful for all your help.
'--- Create a New Email
Set objOutlookApp = New Outlook.Application
Set objNewEmail = objOutlookApp.CreateItem(olMailItem)
'--- Read the HTML File data and insert into the Email Body
objNewEmail.BodyFormat = olFormatHTML
objNewEmail.Display
Set objTextStream = objFileSystem.OpenTextFile(strTempHTMLFile)
Strbody = "<h4> </h4>" & " <span style='font-size:11.5pt'> "
objNewEmail.HTMLBody = Strbody & "<table style='Margin-Left:5pt'>" & _
objTextStream.ReadAll & "</Table>" & "<br>" & objNewEmail.HTMLBody
CodePudding user response:
I played with table borders, color, width and html created the border as I wanted. But I could not reproduce your problem. Then, I start playing with the cells borders applied when the range to be placed in the mail body received borders. When I placed such thin borders, your problem has been reproduced. My initial code placed xlThick borders...
So, please use the next simple function to add borders on the range to be exported cells:
Sub PlaceBorders(rng As Range)
Dim i As Long
For i = 7 To 12
With rng.Borders(i)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThick 'if here you will use xlThin, only in this case the problem you describe appears...
End With
Next i
End Sub
Don't ask me why it's happening....