attach csv file on email sent from postgres

I have the following code to send emails and wanted to see if it’s possible to attach a csv file?

CREATE OR REPLACE FUNCTION public.send_email_html(text, text, text, text)
 RETURNS integer
 LANGUAGE plperlu
AS $function$
    use Net::SMTP;

    my ($recipientString, $sendFrom, $subject, $message) = @_;
    my @recipients = split /;/, $recipientString;
    my $smtp=Net::SMTP->new("localhost");
        $smtp->datasend("To: $_n");
    $smtp->datasend("Subject: $subjectn");
    $smtp->datasend("Content-Type: text/html;n");

    return 1;

Go to Source
Author: Matias