title: Insert text body and excel table body in email using VBA
body: <p><a href="https://i.stack.imgur.com/IZEnu.png" rel="nofollow noreferrer">The ideal format of the email I wish to automate. Certain parts blacked out for privacy.</a></p>
  <p>I am trying to create an email template for business use that can be sent using VBA because the ultimate goal is that the user can only fill in the blanks via userform therefore the text remains unchanged. I already have the userform, and have coded in such a way that the proper blanks are filled in in the text portion and are included in the email body, however I have not figured out how to include the table as well.</p>
  <p>Here is what I have so far as my attempt to add the table:</p>
  <pre><code>Sub SendEmail(what_address As String, subject_line As String, mail_body As String, claim_info As Range)
  
      Dim olApp As Outlook.Application
      Set olApp = CreateObject(&quot;Outlook.Application&quot;)
      
      Dim olMail As Outlook.MailItem
      Set olMail = olApp.CreateItem(olMailItem)
      
      olMail.To = what_address
      olMail.Subject = subject_line
      olMail.Body = mail_body
      olMail.HTMLBody = RangeToHtml.claim_info
      olMail.Send
      
  End Sub
  
  Sub SendClaimsEmail()
  
      Dim mail_body_message As String
      Dim tracking_number As String
      Dim amount_paid As String
      Dim date_paid As String
      Dim payment_due As String
      Dim claim As Range
      
      Set claim = Nothing
      On Error Resume Next
      'Only send the visible cells in the selection.
      Set claim = Selection.SpecialCells(xlCellTypeVisible)
      Set claim = Sheets(&quot;Sheet1&quot;).RangeToHtml(&quot;B2:C9&quot;).SpecialCells(xlCellTypeVisible, xlTextValues)
      On Error GoTo 0
      
      mail_body_message = Sheet1.Range(&quot;A1&quot;)
      tracking_number = Sheet1.Range(&quot;G2&quot;)
      amount_paid = Sheet1.Range(&quot;G3&quot;)
      date_paid = Sheet1.Range(&quot;G4&quot;)
      payment_due = Sheet1.Range(&quot;G5&quot;)
      mail_body_message = Replace(mail_body_message, &quot;replace_tracking&quot;, tracking_number)
      mail_body_message = Replace(mail_body_message, &quot;replace_amountpaid&quot;, amount_paid)
      mail_body_message = Replace(mail_body_message, &quot;replace_datepaid&quot;, date_paid)
      mail_body_message = Replace(mail_body_message, &quot;replace_pmtdueto&quot;, payment_due)
  
      Call SendEmail(&quot;email@email.com&quot;, &quot;Subject Line&quot;, mail_body_message, claim)
            
      MsgBox &quot;Complete!&quot;
   
  End Sub
  </code></pre>