Sir, I've tried the following script below and here is the result.

a) the "mapis32.exe" process is started by the script so I am automatically
authenticated (w/o outlook running) and send the mail successfully.
b) when I tried attaching a file, the mail was not sent and an undeliverable
message appears in my personal folder (my outlook is configured such that
when i opened it all my mails are transferred to my personal folder). the
part where I attach a file is not working (commented the part for file
attachment). Can you give me a sample of code that I can use? I've already
searched in the OLE-Browser html and I used the objects indicated there but
still I'm not successful in file attachments. Here is the error message from
the undeliverable mail:

# start of message body

Your message did not reach some or all of the intended recipients.

      Subject:  Test
      Sent:     6/19/2003 10:38 AM

The following recipient(s) could not be reached:

      'Rodel Bautista' on 6/19/2003 10:38 AM
            No transport provider was available for delivery to this
recipient.

# end of message body

Note that I'm using Outlook 97, ActivePerl 5.6.1 build 635, Windows XP
Professional.

Here is the script (taken from the pdf file of David N. Blank-Edelman posted
as "Perl for System Administration: Networking Power Hour - Electronic
Mail"):

#! c:\perl\bin\perl

$to="recipient_name";
$subject="Test";
$body="This is a test message\n";
use Win32::OLE;
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
my $session = Win32::OLE->new('MAPI.Session','Logoff');
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();
$session->Logon('profile_name','password','False');
my $message = $session->Outbox->Messages->Add;
my $recipient = $message->Recipients->Add;
$recipient->{Name} = $to;
$recipient->{Type} = 1; # 1 = "To:", 2 = "Cc:", 3 = "Bcc:"
$recipient->Resolve();
$message->{Subject} = $subject;
$message->{Text} = $body;

#$message->Attachments->Add('c:/audit/IN/mail_scripts/auto_mail.pl',1,0,'aut
o_mail.pl');

$message->Update;

$message->Send(0, 0, 0); # now it has been _queued_
undef $session;

#end of script

Can you help me again on this.

Thank you very much.

Rodel D. Bautista

> -----Original Message-----
> From: Charbeneau, Chuck [SMTP:[EMAIL PROTECTED]
> Sent: Wednesday, June 18, 2003 8:13 PM
> To:   'Bautista, Rodel D.(Digitel-GSM)'
> Subject:      RE: Using Outlook in Win32::OLE
> 
> 
> > From: Bautista, Rodel D.(Digitel-GSM) 
> > Subject: RE: Using Outlook in Win32::OLE
> > 
> > 
> > Sir, in as much as I would like to just connect directly to 
> > our exchange server via smtp, we are not allowed to do so by 
> > our security dept. I'll just be using the script on one 
> > machine to automate the mailing of daily logs to our boss. 
> 
> *Ouch*
> 
> In that case, the suggestions that were made regarding scripting reference
> and the use of constants would be best followed before going much further.
> 
> Joe Frazier probably gives the best example.
> 
> You would do well with a decent object reference as well, to help make
> sense
> of the Outlook class structure, and if you don't have VB installed such
> that
> you can use the browser there, Jan Dubois created an excellent web based
> one
> that ships with Activestate's perl port.
> 
> If you have Activestate installed, you can probably find it in:
> 
> <PERLROOT>\html\OLE-Browser\browser.html
> 
> Scroll down to the Microsoft Outlook objects and look at the
> implementation
> methods for the objects that Joe suggested.
> 
> I haven't actually written code to deal with authentication, since I'm
> always authenticated, but if you need help, I'm sure I can crack some out.
> Lord knows I've written plenty of other Outlook handling code.
> 
> Let us know what you come up with and if you run into any log jams.
> 
> Chuck Charbeneau
> Lear Corporation
> Lead Software Applications Engineer
> ccharbeneau at lear dot com
> 
> **********************
> ** LEGAL DISCLAIMER **
> **********************
> 
> This E-mail message and any attachments may contain 
> legally privileged, confidential or proprietary 
> information. If you are not the intended recipient(s),
> or the employee or agent responsible for delivery of 
> this message to the intended recipient(s), you are 
> hereby notified that any dissemination, distribution 
> or copying of this E-mail message is strictly 
> prohibited. If you have received this message in 
> error, please immediately notify the sender and 
> delete this E-mail message from your computer.
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to