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

I got this from earlier post and it works great running in NT DOS where it opens up my Outlook mail with NO problems:
my $outlookmail = "c:/Program Files/Microsoft Office/Office/Outlook.ex +e"; open (CMDLOG,"| $outlookmail") || die "$!"; close CMDLOG || die "$!";
But when I try and put it in a web page it does not work.
Here is Perl/CGI part called "outl.cgi":
#!/usr/local/bin/perl use CGI qw(:standard); #Perl web CGI module use CGI::Carp qw(fatalsToBrowser); my $outlookmail = "c:/Program Files/Microsoft Office/Office/Outlook.ex +e"; open (CMDLOG,"| $outlookmail") || die "$!"; close CMDLOG || die "$!";
Web part:
<html> <head> <title>Untitled</title> </head> <BODY> <FORM ACTION="outl.cgi" METHOD="POST"> <TABLE width="60%"> <table><TR> <TR><TD COLSPAN=2> </TD></TR> <TR> <TD> </TD> <TD align="left"><input type="submit" value="Submit"> </TD> </TR> </TABLE> </FORM> </BODY> </HTML>
Any suggestions????

Replies are listed 'Best First'.
Re: Outlook on web page.
by earthboundmisfit (Chaplain) on Jan 09, 2003 at 13:35 UTC
    Perhaps the real question you should be asking yourself is not how to do this but should this be done. Perhaps you have an innocuous need to open a program via a web form, but I know I'd be pissed as hell if a web page attempted this on my box.

    Assuming the best intentions, the problem is most likely one of permissions. The web server (IIS??) has limited user rights. You may need to set up a virtual directory to the directory where outlook lives and set the most unrestrictive permissions possible. Not a very wise security practice, but probably possible.

    update: I like derby's twist as it gets at the heart of what I was after. I was guessing that the goal might be some sort of a help page intended to get new users accquainted with their mail program, but that makes little sense since Perl would have to be installed locally for that to be feasible. If indeed the intent is to simply send mail via a web form, there are much, much easier ways to accomplish the goal as noted by derby.

    ---- I am what I read

      earthboundmisfit++ for Perhaps the real question you should be asking yourself is not how to do this but should this be done.
      but my twist Perhaps the real question you should be asking yourself is what are you trying to accomplish?

      Looking at your script, I can only guess that your trying to open outlook so you can send mail. Is that correct? (Your use of the pipe leads me to believe this is so). The main issue I have with this approach is that since outlook is a GUI program (unless I'm missing something),you will never reach the close line of your script until someone quits the GUI - something that will tick of your web server admins. If you just want to create a webpage that will send mail to someone, take a look at Mail::Mailer.


      update Are you sure this isn't working in your cgi-script? If your web server is a different machine than your local workstation, after you invoke the cgi-script, walk over to the server and see if outlook has "popped" up on it.

Re: Outlook on web page.
by Anonymous Monk on Jan 09, 2003 at 13:37 UTC
    You need to give more information. If your CGI is running on a *nix box, it will have a tough time knowing where your C drive is located. :)
      Thanks for all the information. I am running this on a NT server and would like to just start getting it to work on my local workstation. I tried this in my local cgi bin and cant get it to work yet it works when I run it in DOS:
      my $outlookmail = "c:/Program Files/Microsoft Office/Office/Outlook.ex +e" ; open (CMDLOG,"| $outlookmail") || die "failed to open: $!\n"; close CMDLOG || die "failed to close: $!\n";;
      Anymore suggestions?
        Like others in this thread I have to question what your goal is here, and you haven't stated it clearly. While the above code will start an Outlook client, I don't see the point of doing this from a CGI or any Perl script. That's what the start menu is for :).

        Now, if your goal is to have your Perl script make Outlook actually do something besides show the GUI, you should look at Win32::OLE. Note that to make use of this module, you will have to understand the Outlook object model.

Re: Outlook on web page.
by del (Pilgrim) on Jan 10, 2003 at 06:04 UTC
    If sending mail from your script is your goal, have you considered Blat or perhaps some of the Mail:: modules?

    I know neither of these options address your possible need to call the Outlook executable itself, but you may be able to accomplish your task another way.