#!/usr/bin/perl use LWP::Simple; use MIME::Lite; use Spreadsheet::WriteExcel; $from = 'abc\@gmail.com'; $to = 'def\@gmail.com'; $Subject = 'Daily Social Media search'; my $url = "abc.org/?xyz=csv"; my $file = "/Users/abc/Desktop/abc.csv"; my $status = mirror($url,$file); die "Cannot retrieve $url" unless is_success($status); # Part using which the file being downloaded is sent as an attachment to an email # $msg = MIME::Lite->new( From => $from, To => $to, Subject => $Subject, Type => 'multipart/Mixed', ); $msg->attach( Type => 'Text', Data => "The attachment contains the csv file downloaded today." ); $msg->attach( Type => 'Application/Text', Path => "/Users/abc/Desktop/abc.csv" ); print "Mail Sent\n"; $msg->send; # send via default