I've got a script that populates objects on an Exchange server by automating
MS Outlook through Win32::OLE. When I run it interactively, it works fine.
When I run it as a scheduled task at night, it fails.

I get an error like this in my event log:

    Win32::OLE(0.1502) error 0x80040102: "Invalid window handle";
    in METHOD/PROPERTYGET "Folders" at exporter.pl line 139.

My code looks like this:

    use Win32::OLE;
    use Win32::EventLog::Carp;
    Win32::OLE->Option(Warn => \&Win32::EventLog::Carp::croak);

    ...

    my $outlook = Win32::OLE->GetActiveObject('Outlook.Application') ||
              Win32::OLE->new('Outlook.Application', 'Quit') ||
              die 'Unable to open Outlook';
    my $namespace = $outlook->GetNamespace('MAPI');

    ...

    $folder = $namespace->Folders($path[1]); # exporter.pl line 139

$path[1] is defined and the folder exists. (I added a log entry just before
that line to be sure.)

My hunch is that it wants to display stuff to the screen and can't when I'm
not really logged in. Is there some way around that?

Any ideas appreciated. Thanks.

--
Scott Lamb
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to