To: $email
Subject: $subject
Mime-Version: 1.0
Content-Type: multipart/related;boundary="nfcoremimeboundary"

--nfcoremimeboundary
Content-Type: text/html; charset=utf-8

$email_html

--nfcoremimeboundary
Content-Type: image/png;name="nfcore-atacseq_logo.png"
Content-Transfer-Encoding: base64
Content-ID: <nfcoreatacseqlogo>
Content-Disposition: inline; filename="nfcore-atacseq_logo.png"

<% out << new File("$baseDir/assets/nfcore-atacseq_logo.png").
  bytes.
  encodeBase64().
  toString().
  tokenize( '\n' )*.
  toList()*.
  collate( 76 )*.
  collect { it.join() }.
  flatten().
  join( '\n' ) %>

<%
if (mqcFile){
def mqcFileObj = new File("$mqcFile")
if (mqcFileObj.length() < mqcMaxSize){
out << """
--nfcoremimeboundary
Content-Type: text/html; name=\"multiqc_report\"
Content-Transfer-Encoding: base64
Content-ID: <mqcreport>
Content-Disposition: attachment; filename=\"${mqcFileObj.getName()}\"

${mqcFileObj.
  bytes.
  encodeBase64().
  toString().
  tokenize( '\n' )*.
  toList()*.
  collate( 76 )*.
  collect { it.join() }.
  flatten().
  join( '\n' )}
"""
}}
%>

--nfcoremimeboundary--
