+ # Generate the content of the csv with headers
+ my $content = join(";", qw(title name surname address1 address2 zipcode city email itemcount itemsinfo due_date issue_date)) . "\n";
+ $content .= join( "\n", @output_chunks );
+
+ my $attachment = {
+ filename => defined $csvfilename ? 'attachment.csv' : 'attachment.txt',
+ type => 'text/plain',
+ content => $content,
+ };
+
+ my $letter = {
+ title => 'Overdue Notices',
+ content => 'These messages were not sent directly to the patrons.',
+ };
+ C4::Letters::EnqueueLetter(
+ { letter => $letter,
+ borrowernumber => undef,
+ message_transport_type => 'email',
+ attachments => [$attachment],
+ to_address => $admin_email_address,
+ }
+ );