While I'm a fan of Mail::Sender :-), on Windows 2000 and XP there's also CDO
to think about as an alternative mail delivery mechanism.   The below sends
e-mail messages without the use of the SMTP service.  I was sort of messing
about with this earlier, and have not included all of the other
attributes/functions available (like attachments), but hopefully it conveys
the general idea.

Regards,
Richard
 

use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Enum;
#use Win32::OLE::Const 'Microsoft CDO for Exchange 2000 Library';
use Win32::OLE::Const 'Microsoft CDO for Windows 2000 Library';
use Win32::OLE::Const 'Microsoft CDO 1.21 Library';

$Win32::OLE::Warn = 3;
my $objCDOMsg = Win32::OLE->new('CDO.Message');

my $cdoSendUsingMethod       =
'http://schemas.microsoft.com/cdo/configuration/sendusing';
my $cdoSMTPServer            =
'http://schemas.microsoft.com/cdo/configuration/smtpserver';
my $cdoSMTPServerPort        =
'http://schemas.microsoft.com/cdo/configuration/smtpserverport';
my $cdoSMTPConnectionTimeout =
'http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout';
my $cdoSMTPAuthenticate      =
'http://schemas.microsoft.com/cdo/configuration/smtpauthenticate';
my $cdoSendUserName          =
'http://schemas.microsoft.com/cdo/configuration/sendusername';
my $cdoSendPassword          =
'http://schemas.microsoft.com/cdo/configuration/sendpassword';
my $cdoSendReplyAddr         =
'http://schemas.microsoft.com/cdo/configuration/senduserreplyemailaddress';
my $cdoSMTPUseSSL                    =
'http://schemas.microsoft.com/cdo/configuration/smtpusessl';
my $cdoSensitivity           =
'http://schemas.microsoft.com/exchange/sensitivity';
my $cdoImportance            = 'urn:schemas:httpmail:importance';
my $cdoAttachmentFilename    = "urn:schemas:httpmail:attachmentfilename";
my $cdoBcc                   = "urn:schemas:httpmail:bcc";
my $cdoCc                    = "urn:schemas:httpmail:cc";

my $cdoAnonymous       = '0'; # Do not authenticate. 
my $cdoBasic           = '1'; # Use basic (clear-text) authentication. 
my $cdoNTLM            = '2'; # Use NTLM authentication (Secure Password
Authentication).
                                        # The current process security
context is used to authenticate. 

my $cdoSensitivityNone = '0'; # Not specified 
my $cdoPersonal        = '1'; # Personal 
my $cdoPrivate       = '2'; # Private 
my $cdoConfidential    = '3'; # Confidential 

my $cdoLow             = '0'; # Low importance 
my $cdoNormal          = '1'; # Normal importance 
my $cdoHigh            = '2'; # High importance 

my $cdoSendUsingPickup = '1'; # Send message using the local SMTP service
pickup directory. 
my $cdoSendUsingPort   = '2'; # Send the message using the network (SMTP
over the network).  

my $strServer          = "smtp.mycompany.com";
my $strSender          = "cdotest\@mycompany.com";
my $strRecip           = "user_a\@mycompany.com";
my $strCC              = "user_b\@mycompany.com";
my $strSubj            = "CDO Message Test";
my $strBody            = "this is a test";

$objCDOMsg->{'From'}     = $strSender;
$objCDOMsg->{'To'}       = $strRecip;
$objCDOMsg->{'Subject'}  = $strSubj;
$objCDOMsg->{'Textbody'} = $strBody;

$objCDOMsg->Configuration->Fields->Item($cdoSendUsingMethod)->{Value}   =
$cdoSendUsingPort;
$objCDOMsg->Configuration->Fields->Item($cdoSMTPServer)->{Value}        =
$strServer;
$objCDOMsg->Configuration->Fields->Item($cdoSMTPServerPort)->{Value}    =
'25';

#$objCDOMsg->Configuration->Fields->Item($cdoSMTPUseSSL)->{Value}        =
1;
#$objCDOMsg->Configuration->Fields->Item($cdoSMTPAuthenticate)->{Value}  =
$cdoBasic;
#$objCDOMsg->Configuration->Fields->Item($cdoSendUserName)->{Value}      =
"DOMAIN\\userid";
#$objCDOMsg->Configuration->Fields->Item($cdoSendPassword)->{Value}      =
"password";

$objCDOMsg->Configuration->Fields->Update;
$objCDOMsg->Fields->Item($cdoImportance)->{Value}         = $cdoHigh;
$objCDOMsg->Fields->Item($cdoSensitivity)->{Value}        =
$cdoConfidential;
$objCDOMsg->Fields->Item($cdoCc)->{Value}                 = $strCC;
$objCDOMsg->Fields->Update;

$objCDOMsg->Send;
undef($objCDOMsg);




> -----Original Message-----
> From: Jenda Krynicky [mailto:Jenda@;Krynicky.cz] 
> Sent: Tuesday, October 22, 2002 1:04 PM
> To: [EMAIL PROTECTED]; 
> [EMAIL PROTECTED]
> Subject: Re: difficulties mailing on win32 - none on Unix
> 
> 
> From:                 [EMAIL PROTECTED]
> > I am new to this list, (and a bit of a newbie with perl), 
> so apologies 
> > if this has been covered before - I have searched the faqs but can 
> > only find standard examples.
> > 
> > Anyhow, I have some scripts which use Net::SMTP to mail data, and 
> > these have been working fine while hosted on a Unix box.
> > 
> > For operational reasons, I have recently installed 
> ActivePerl Win32 on 
> > a Windows XP box and have moved my site and scripts to this. 
> > Everything works normally, except the mail routines. I have tried 
> > Mail::Sender and get the same problems -
> > 
> > In all the scripts, using the new constructor fails (returns -1).
> 
> -1 means "The SMTP server ... was not found" in Mail::Sender.
> 
> Are you sure you have the address right?
> 
> Jenda
> ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
> When it comes to wine, women and song, wizards are allowed 
> to get drunk and croon as much as they like.
>       -- Terry Pratchett in Sourcery
> 
> _______________________________________________
> Perl-Win32-Users mailing list 
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to