I'm not sure what mail modules are available for Win32 but I routinely use something like this for sending email via Microsoft Outlook. It works well enough if all you need to do is send email from the account on your Win2K box. You'll need Win32::OLE.
sub send_outlook_mail
{
#use OLE and Outlook to send an email message
my $to = shift || croak "required parameter (to address) missing";
my $subject = shift;
$subject = "" if not defined $subject;
my $body = shift;
$body = "" if not defined $body;
my $cc = shift;
$cc = "" if not defined $cc;
#get new Outlook instance
my $mail = new Win32::OLE('Outlook.Application');
croak "Unable to start Outlook instance: $!" if !defined $mail;
my $item = $mail->CreateItem(0);
croak "Unable to create mail item: $!" if !defined $item;
$item->{'To'} = $to;
$item->{'CC'} = $cc;
$item->{'Subject'} = $subject;
$item->{'Body'} = $body;
#rest of args are file attachments
foreach my $attach (@ARGV)
{
# print STDERR "File attachment: $attach\n";
#make sure the attachment is really there
croak "Missing attachment $attach: $!" if !-e $attach;
my $attachments = $item->Attachments();
$attachments->Add($attach);
}
#send it
$item->Send();
my $error = Win32::OLE->LastError();
carp "Win32::OLE error: $error" if $error;
} #sub send_outlook_mail
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|