Kirby_Sarah <[EMAIL PROTECTED]> writes: > Hi all, > > I was wondering, can Perl create and format a Word document using a > template and can Perl create draft copies of Emails with (or without) > attachments? I want to automate a report process so that perl generates the > reports (which I do right now into HTML format that I then save as a Word > document) and creates the emails so I can send them out. I need drafts > because some of the emails need to have additional addresses added on > manually. > > -Sarah Kirby > LAN Support > BLS
The first is probably fairly difficult. Perhaps use search.cpan.org to find a perl module which will output word documents. I know there's one for Excel, but I've never had a reason to use one for Word. For the second, you can create a template file like so: template.txt ' Dear {salutation} {first_name} {last_name}, Congratulations! You may have already won {amount}. That's right, {first_name}, the lifestyle of your dreams could be at hand! Blah blah blah. ' And open it, replace the tags like so: ' #!/usr/bin/perl -wl use strict; open TEMPLATE, "template.txt" or die "Could not open template.txt: $!"; local $/ = undef; my $temp = <TEMPLATE>; close TEMPLATE; my %repl = ( first_name => 'Sarah', last_name => 'Kirby', salutation => 'Ms.', amount => '$100,000,000' ); foreach my $key (keys %repl) { $temp =~ s/\{$key\}/$repl{$key}/gi; } print $temp; ' Replacing 'print $temp', with whatever e-mail code you wish to send. You could, for instance, loop over an array of user records, do the substitution for each on a copy of '$temp', and e-mail them to the appropriate user. -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]