From John_Warner at Dell.com Wed Oct 5 07:46:38 2011 From: John_Warner at Dell.com (John_Warner at Dell.com) Date: Wed, 5 Oct 2011 09:46:38 -0500 Subject: APM: x64 Strawberry Perl 5.12.3 and OLE Message-ID: <49D22114906FA94DA7035A6A4E79C2C7777F8803C1@AUSX7MCPC101.AMER.DELL.COM> After a looong absence from programming, I find myself with the need to automate some tasks that I'd like to use Perl to solve. I've run into an oddity that I don't know how to work around. The following code works on x86 Windows 7 with ActiveState Perl 5.10.1 but not on x64 Windows 7 with either ActiveState or Strawberry Perl. I think there is something different about OLE under x64 Windows that is broken in Perl. Sample code: use Mail::Outlook; use Win32::OLE::Const 'Microsoft Outlook'; # create an instance of Outlook print "Attempting to create Outlook object......"; my $outlook; die "Whoops! $!\n" unless $outlook = new Mail::Outlook(); print "\nOpening the Inbox......"; my $folder = $outlook->folder('Inbox') || die "Unable to open folder Inbox.. $!\n"; # get the first message in the folder print "\nReading first message......"; my $message = $folder->first() || die "Unable to get to first message in the inbox\n"; print "\nMessages:\n"; while ($message) { print "From: ", $message->From(),"\n"; print "Subject: ", $message->Subject(),"\n\n"; $message = $folder->next(); } Under x86 Windows, I get the expected output (a list of items from my Inbox) but under x64 Windows I get... C:\Projects>perl test3.pl Loading Mail::Outlook Loading Win32::OLE::Const Whoops! Attempting to create Outlook object...... This is puzzling because it prints out the failure message (Whoops!) before the attempting message. Has anybody else encountered this? Is there a work around? Should I be using something other than OLE? John Warner Dell | Systems Management Software Lab office +1 512 723 2793, 800 945 3355 ext 7232793 john_warner at dell.com Dell Inc. One Dell Way, MS RR5-P170, Round Rock, TX 78682 Office Hours: Tuesday - Friday 7:00 am - 5:00 pm CDT How am I doing? Email my manager Leah Spence at Leah_Spence at dell.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From John_Warner at Dell.com Wed Oct 5 12:33:57 2011 From: John_Warner at Dell.com (John_Warner at Dell.com) Date: Wed, 5 Oct 2011 14:33:57 -0500 Subject: APM: x64 Strawberry Perl 5.12.3 and OLE In-Reply-To: References: <49D22114906FA94DA7035A6A4E79C2C7777F8803C1@AUSX7MCPC101.AMER.DELL.COM> Message-ID: <49D22114906FA94DA7035A6A4E79C2C7777F880923@AUSX7MCPC101.AMER.DELL.COM> I did find these articles but since I'm not getting any error message, I wasn't sure if the first article applied to me. I can try a 32-bit Perl again now that I know there are two different versions of command prompt on x64 Windows. Through pure happenstance (ok, user error), I installed 32-bit Perl on my x64 Win7 system which didn't work at all from a regular (aka 64-bit) command prompt. Eventually, I was able to determine that I needed a 32-bit command prompt but the symptoms did not change with the 64-bit version of Perl installed or using wperl. It is the 32-bit shell that provided the output in my question. I will try installing a 32-bit version of Perl and see if the results change. I've never had to right a wrapper before. How hard is it? Any guidance on where I should go to educate myself and any pointers/tips would be appreciated. Thanks! From: Montgomery Conner [mailto:montgomery.conner at gmail.com] Sent: Wednesday, October 05, 2011 1:56 PM To: Warner, John Subject: Re: APM: x64 Strawberry Perl 5.12.3 and OLE It seems that your issue stems from using Win32::OLE with a version of Perl that may have been compiled for 64 bit address space. It seems that on the Windows platform a 64 bit process (perl in this case) will not have correct access to the 32 bit address space of the underlying Win32::OLE DLL. Can you use a 32 bit Perl on the problem systems? Google reveals enlightenment from the perlmonks, here: http://www.perlmonks.org/?node_id=824725 http://www.perlmonks.org/?node_id=825142 Hope that helps, Montgomery On Wed, Oct 5, 2011 at 9:46 AM, > wrote: After a looong absence from programming, I find myself with the need to automate some tasks that I'd like to use Perl to solve. I've run into an oddity that I don't know how to work around. The following code works on x86 Windows 7 with ActiveState Perl 5.10.1 but not on x64 Windows 7 with either ActiveState or Strawberry Perl. I think there is something different about OLE under x64 Windows that is broken in Perl. Sample code: use Mail::Outlook; use Win32::OLE::Const 'Microsoft Outlook'; # create an instance of Outlook print "Attempting to create Outlook object......"; my $outlook; die "Whoops! $!\n" unless $outlook = new Mail::Outlook(); print "\nOpening the Inbox......"; my $folder = $outlook->folder('Inbox') || die "Unable to open folder Inbox.. $!\n"; # get the first message in the folder print "\nReading first message......"; my $message = $folder->first() || die "Unable to get to first message in the inbox\n"; print "\nMessages:\n"; while ($message) { print "From: ", $message->From(),"\n"; print "Subject: ", $message->Subject(),"\n\n"; $message = $folder->next(); } Under x86 Windows, I get the expected output (a list of items from my Inbox) but under x64 Windows I get... C:\Projects>perl test3.pl Loading Mail::Outlook Loading Win32::OLE::Const Whoops! Attempting to create Outlook object...... This is puzzling because it prints out the failure message (Whoops!) before the attempting message. Has anybody else encountered this? Is there a work around? Should I be using something other than OLE? John Warner Dell | Systems Management Software Lab office +1 512 723 2793, 800 945 3355 ext 7232793 john_warner at dell.com Dell Inc. One Dell Way, MS RR5-P170, Round Rock, TX 78682 Office Hours: Tuesday - Friday 7:00 am - 5:00 pm CDT How am I doing? Email my manager Leah Spence at Leah_Spence at dell.com _______________________________________________ Austin mailing list Austin at pm.org http://mail.pm.org/mailman/listinfo/austin -------------- next part -------------- An HTML attachment was scrubbed... URL: From John_Warner at Dell.com Thu Oct 6 14:17:02 2011 From: John_Warner at Dell.com (John_Warner at Dell.com) Date: Thu, 6 Oct 2011 16:17:02 -0500 Subject: APM: x64 Strawberry Perl 5.12.3 and OLE In-Reply-To: <49D22114906FA94DA7035A6A4E79C2C7777F880923@AUSX7MCPC101.AMER.DELL.COM> References: <49D22114906FA94DA7035A6A4E79C2C7777F8803C1@AUSX7MCPC101.AMER.DELL.COM> <49D22114906FA94DA7035A6A4E79C2C7777F880923@AUSX7MCPC101.AMER.DELL.COM> Message-ID: <49D22114906FA94DA7035A6A4E79C2C7777F8E62B8@AUSX7MCPC101.AMER.DELL.COM> Happily, I can report that I was able to make my program work on x64 Windows but I had to do the following: 1. Install x86 version of Perl on my x64 Windows 7 system 2. Run the perl program from within a 32-bit DOS shell (c:\windows\SysWOW64\cmd.exe) I received the same results as before when I ran the test script using either perl.exe or wperl.exe inside a standard command shell. So it seems something is broken with Mail::Outlook or possibly OLE in Perl under x64 Windows. After rooting around and looking at the source code for Outlook.pm, Folder.pm, and Message.pm, I don't think the problem is there but then again I didn't try stepping through the program so I can't be 100% certain. However, the code in all three modules looks to be nothing more than standard Perl. John From: austin-bounces+john_warner=dell.com at pm.org [mailto:austin-bounces+john_warner=dell.com at pm.org] On Behalf Of Warner, John Sent: Wednesday, October 05, 2011 2:34 PM To: austin at pm.org Subject: Re: APM: x64 Strawberry Perl 5.12.3 and OLE I did find these articles but since I'm not getting any error message, I wasn't sure if the first article applied to me. I can try a 32-bit Perl again now that I know there are two different versions of command prompt on x64 Windows. Through pure happenstance (ok, user error), I installed 32-bit Perl on my x64 Win7 system which didn't work at all from a regular (aka 64-bit) command prompt. Eventually, I was able to determine that I needed a 32-bit command prompt but the symptoms did not change with the 64-bit version of Perl installed or using wperl. It is the 32-bit shell that provided the output in my question. I will try installing a 32-bit version of Perl and see if the results change. I've never had to right a wrapper before. How hard is it? Any guidance on where I should go to educate myself and any pointers/tips would be appreciated. Thanks! From: Montgomery Conner [mailto:montgomery.conner at gmail.com] Sent: Wednesday, October 05, 2011 1:56 PM To: Warner, John Subject: Re: APM: x64 Strawberry Perl 5.12.3 and OLE It seems that your issue stems from using Win32::OLE with a version of Perl that may have been compiled for 64 bit address space. It seems that on the Windows platform a 64 bit process (perl in this case) will not have correct access to the 32 bit address space of the underlying Win32::OLE DLL. Can you use a 32 bit Perl on the problem systems? Google reveals enlightenment from the perlmonks, here: http://www.perlmonks.org/?node_id=824725 http://www.perlmonks.org/?node_id=825142 Hope that helps, Montgomery On Wed, Oct 5, 2011 at 9:46 AM, > wrote: After a looong absence from programming, I find myself with the need to automate some tasks that I'd like to use Perl to solve. I've run into an oddity that I don't know how to work around. The following code works on x86 Windows 7 with ActiveState Perl 5.10.1 but not on x64 Windows 7 with either ActiveState or Strawberry Perl. I think there is something different about OLE under x64 Windows that is broken in Perl. Sample code: use Mail::Outlook; use Win32::OLE::Const 'Microsoft Outlook'; # create an instance of Outlook print "Attempting to create Outlook object......"; my $outlook; die "Whoops! $!\n" unless $outlook = new Mail::Outlook(); print "\nOpening the Inbox......"; my $folder = $outlook->folder('Inbox') || die "Unable to open folder Inbox.. $!\n"; # get the first message in the folder print "\nReading first message......"; my $message = $folder->first() || die "Unable to get to first message in the inbox\n"; print "\nMessages:\n"; while ($message) { print "From: ", $message->From(),"\n"; print "Subject: ", $message->Subject(),"\n\n"; $message = $folder->next(); } Under x86 Windows, I get the expected output (a list of items from my Inbox) but under x64 Windows I get... C:\Projects>perl test3.pl Loading Mail::Outlook Loading Win32::OLE::Const Whoops! Attempting to create Outlook object...... This is puzzling because it prints out the failure message (Whoops!) before the attempting message. Has anybody else encountered this? Is there a work around? Should I be using something other than OLE? John Warner Dell | Systems Management Software Lab office +1 512 723 2793, 800 945 3355 ext 7232793 john_warner at dell.com Dell Inc. One Dell Way, MS RR5-P170, Round Rock, TX 78682 Office Hours: Tuesday - Friday 7:00 am - 5:00 pm CDT How am I doing? Email my manager Leah Spence at Leah_Spence at dell.com _______________________________________________ Austin mailing list Austin at pm.org http://mail.pm.org/mailman/listinfo/austin -------------- next part -------------- An HTML attachment was scrubbed... URL: