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

Maybe this is a bit much, but I'll ask anyway.

I would like suggestions.

Here is what I am trying to do:

I would like to have an application that reads e-mail as it comes in (from an MS Exchange Server), converts the subject and the body of the text to be placed in a template (used by another program for helpdesk tickets), then sends the mail via SMTP to another mail account.

The application needs to run in the background as a service, and has to log on as a service to the machine that it will be run on (That way the default Exchange profile can be used.)

Here's what I've found to be useful so far:

win32::MAPI

win32::API

Net::Telnet (Instead of Net::SMTP, I don't know why, just did)

I think the real issue will be the running as a service user for the exchange profile so that the Win32::MAPI module works properly.

Any ideas/suggestions? :-)

-Josh

Replies are listed 'Best First'.
Re: MAPI & Windows 2000 Service Daemon
by $code or die (Deacon) on Aug 30, 2001 at 05:03 UTC
    In addition to HamNRye's answer, there are a few Perl tools that will help.

    Win32::Daemon will allow you to set your script up as a Windows Service. It is more powerful than srvany.exe because it gives you access to the service control manager inside your service so you can see if the service is paused, etc and execute bits of code when the service is paused\started\resumed - useful for clean service operation. Also with srvany.exe - if you pause your service, it pauses srvany.exe and not your script - it just keeps running.

    If you want to run a command as a specific user, you can use Win32::AdminMisc's LogonAsUser() and CreateProcessAsUser() functions.

    I'm not very familiar with Exchange, so I am not sure if this answers your question.

    Error: Keyboard not attached. Press F1 to continue.
Re: MAPI & Windows 2000 Service Daemon
by HamNRye (Monk) on Aug 30, 2001 at 03:34 UTC

    The way I understand it, you are looking to "run as user" so that you can access the correct MAPI account?? And in addition you are looking to run as a daemon?? Look at "srvany.exe". This will allow you to start your program as a service, as well as run as user name.

    In addition, using the Windows Scripting Host with PerlScript allows you to schedule the task to run as a user.

    In addition, you get a nifty little Win2k utility called, oddly enough, "runas". C:\> runas nobody perl myscript.pl

    ~Hammy