I want my script to email report as an attachment. No error is reported and email is sent with attachment but when attached file is opened, it is all garbage!!
Here is my code-
my $mail_host = 'server name';
my $attach = "daily_summary.csv";
my $body = "See attached reports.\n";
### Create the multipart container
my $msg = MIME::Lite->new (
From => $from,
To => $to,
Subject => $subject,
) or die "Error creating multipart container: $!\n";
### Add the text message part
Type => 'TEXT',
Data => $body
) or die "Error adding the text message part: $!\n";
### Add the file
Type => 'text/csv',
Path => 'csv file path',
Filename => $attach,
Disposition => 'attachment'
) or die "Error adding $attach : $!\n";
### Send the Message
MIME::Lite->send('smtp', $mail_host, Timeout=>60);
Any help will be greatly appreciated.