title: Attach files in batches of 7, change Subject & Body accordingly
body: <p>The below code attaches one file per email. I need to attach seven files from the folder.</p>
  <p>I have approximately 150 files.</p>
  <p>I need to</p>
  <ol>
  <li><p>In the first email attach the first 7 files and then loop to attach 7 files to each subsequent email then in the last email attach the remaining three PDF files.</p>
  </li>
  <li><p>Subject for the first email: Invoice 001 to Invoice 007<br />
  Body for First Email:<br />
  Please find attached the following invoices<br />
  Invoice 001 to Invoice 007 (7 invoices)<br />
  ...<br />
  Subject for the last email: Invoice 148 to Invoice 150<br />
  Body for last Email:<br />
  Please find attached the following invoices<br />
  Invoice 148 to Invoice 150 (3 invoices)</p>
  </li>
  </ol>
  <pre class="lang-vb prettyprint-override"><code>Sub sendmailsss()
      
      Dim path As String
      Dim counter As Integer
      
      counter = ThisWorkbook.Worksheets(&quot;Sheet&quot;).Range(&quot;I4&quot;)
      path = ThisWorkbook.Worksheets(&quot;Sheet&quot;).Range(&quot;M2&quot;)
      If ThisWorkbook.Worksheets(&quot;Sheet&quot;).Range(&quot;M2&quot;) = &quot;&quot; Then
          MsgBox &quot;No folder selected. Please Select a folder with Invoives.&quot;
          Exit Sub
      End If
      fpath = path &amp; &quot;\*.pdf&quot;
      fname = Dir(path)
      
      Dim OutApp As Outlook.Application
      Dim Source As String
      Dim subj() As String
      Do While fname &lt;&gt; &quot;&quot;
          subj = Split(fname, &quot;.&quot;)
          Set OutApp = CreateObject(&quot;Outlook.Application&quot;)
          On Error GoTo 0
          Dim OutMail As Outlook.MailItem
          Dim OutAccount As Outlook.Account
          Set OutAccount = OutApp.Session.Accounts.Item(2)
      
          Set OutMail = OutApp.CreateItem(olMailItem)
          Source = path &amp; fname
          With OutMail
              .To = &quot;info@abc.co.uk&quot;
              .Subject = &quot;Company Ltd &quot; &amp; subj(0)
              .HTMLBody = &quot;Invoice attached&quot;
              .Attachments.Add Source
              .SendUsingAccount = OutAccount
      
              '.Display
              .Send
          End With
          If Err Then
              MsgBox &quot;Error while sending Email&quot; &amp; vbLf &amp; &quot;Press OK to check it in the Outlook&quot;, vbExclamation
              '.Display
          Else
              ms = ms + 1
          End If
          On Error GoTo 0
          Application.Wait Now + #12:00:10 AM#
      
          fname = Dir()
          'If ms = 3 Then
          '    Exit Do
          'End If
      Loop
      MsgBox &quot;Process Completed. &quot; &amp; ms &amp; &quot; emails sent.&quot;
  End Sub
  </code></pre>