Border
Border
PgStart = "<html><body>"
'Create the html table and header from the first row
tableHdr = "<table border=1><tr><th>" & Range("A1").Value & "</th>" _
& "<th>" & Range("B1").Value & "</th>" _
& "<th>" & Range("C1").Value & "</th>" _
& "<th>" & Range("D1").Value & "</th>" _
& "<th>" & Range("E1").Value & "</th>" _
& "<th>" & Range("F1").Value & "</th>" _
NmeRow = cell.Row
'Second loop checks the email addresses of all cells following the current cell in the first
loop.
'Yes will be appended on any duplicate finds and another row added to the mailbody table
For Each dwn In rng.Offset(NmeRow - 1, 0)
End If
' Clear additional table row variable ready for next
AddRow = ""
Next
With OutMail
.To = MailTo
.CC=mailcc
.Subject = MailSubject
.HTMLBody = PgStart & MsgStr & tableHdr & MailBody & "</table></body></html>"
.Display
'send
End With
End If
End If
MailTo = ""
MailSubject = ""
MailBody = ""
Next
Application.DisplayAlerts = False
Worksheets("MailBody").Delete
Application.DisplayAlerts = True
End If
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "MailBody"
mWs.Rows(1).Copy Destination:=Worksheets("MailBody").Range("A1")
mWs.Activate
i = rng.Rows.Count
cRow = cell.Row
'Copy the row to the first empty row in the MailBody sheet
MailSubject = "Subject?"
'Second loop checks the email addresses of all cells following the current cell in the first loop.
'Yes will be appended on any duplicate finds and another row added to the MailBody sheet
End If
Next
'Autofit the copied rows on the new sheet, otherwise they'll be copied to the mail with defaults widths,
heights
With Worksheets("MailBody")
End With
'Create mail
With OutMail
.To = MailTo
.CC = mailcc
.Subject = MailSubject
.Display
'send
End With
With Worksheets("MailBody")
End With
End If
End If
MailTo = ""
MailSubject = ""
Next
Application.DisplayAlerts = False
Worksheets("MailBody").Delete
Application.DisplayAlerts = True
End Sub
Dim ts As Object
TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
'Copy the range and create a new workbook to past the data in
rng.Copy
Set TempWB = Workbooks.Add(1)
With TempWB.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).Select
Application.CutCopyMode = False
.DrawingObjects.Visible = True
.DrawingObjects.Delete
On Error GoTo 0
End With
With TempWB.PublishObjects.Add( _
SourceType:=4, _
filename:=TempFile, _
Sheet:=TempWB.Sheets(1).Name, _
Source:=TempWB.Sheets(1).UsedRange.Address, _
HtmlType:=0)
.Publish (True)
End With
RangetoHTML = ts.readall
ts.Close
'Close TempWB
TempWB.Close savechanges:=False
Kill TempFile
Set ts = Nothing
End Function
On Error GoTo 0
End Function