1#!/usr/local/bin/perl -w
2
3###############################################################################
4#
5# Example of how to use Mail::Sender to send a Spreadsheet::WriteExcel Excel
6# file as an attachment.
7#
8# The main thing is to ensure that you close() the Worbook before you send it.
9#
10# See the L<Mail::Sender> module for further details.
11#
12# reverse('�'), August 2002, John McNamara, jmcnamara@cpan.org
13#
14
15
16use strict;
17use Spreadsheet::WriteExcel;
18use Mail::Sender;
19
20# Create an Excel file
21my $workbook  = Spreadsheet::WriteExcel->new("sendmail.xls");
22my $worksheet = $workbook->add_worksheet;
23
24$worksheet->write('A1', "Hello World!");
25
26$workbook->close(); # Must close before sending
27
28
29
30# Send the file.  Change all variables to suit
31my $sender = new Mail::Sender
32{
33    smtp => '123.123.123.123',
34    from => 'Someone'
35};
36
37$sender->MailFile(
38{
39    to      => 'another@mail.com',
40    subject => 'Excel file',
41    msg     => "Here is the data.\n",
42    file    => 'mail.xls',
43});
44
45
46