engrbob has asked for the wisdom of the Perl Monks concerning the following question:

Can someone explain this error message?

-snip-

my $mapiSession = Win32::OLE->new("MAPI.Session"); die "Cannot create session\n" if not defined($mapiSession);

-error message-

Win32::OLE(0.1601) error 0x80010106: "Cannot change thread mode after +it is set" at mail.pl line 16 eval {...} called at mail.pl line 16 Cannot create session
I can do this with VB on the same machine so I'm assuming the CDO.dll is ok. I can also do a
my $xl = Win32::OLE->new("Excel.Application");
without generating an error so I figure Win32::OLE is ok too. Any insights?

engrbob

Replies are listed 'Best First'.
Re: Using the Win32 CDO library
by jand (Friar) on Apr 25, 2003 at 19:31 UTC
    CDO may want to run in apartment threaded mode. Try adding the following line directly after your use Win32::OLE statement:
    Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE());
    and see if it makes a difference.
      You are awesome! bob