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

Hi, Has anybody got any pointers as to how to get outlook to call a perl program on receipt of a particular mail message. I cant find diddly on 'custom action' rules and need to show these 'VB' boys the 'light'. Regards Kevin

Replies are listed 'Best First'.
Re: Outlook - Custom Action
by jaa (Friar) on Nov 27, 2003 at 15:18 UTC
    Looks like you need to create a Custom Action wrapper that will let you then execute perl with your script.

    Here is a URL: http://support.microsoft.com/?kbid=198725

    This provides an MS C++ example of a Custom Action

    I would guess you need to hook it up with the WIN equivalent of a system("perl -w myscript.pl") call, after feeding it the message details.

    Regards,
    Jeff

      and looking further at the MS example arghh! I guess it would be nice to be able to exec a perl script from the MS Outlook rules, but maybe it would be easier to use Perl to check your mail before letting Outlook have a look?

      If you have to run it on the client, maybe use Mail::POP3Client class or something similar to process the remote mail before letting Outlook have a peek?

      But then again... you might have issues with keeping ahead of the 5 minute scheduled Outlook downloads...

      If I was doing this, I would probably be hooking into the smtp receiving process on the mail server, or have a daemon post-process the users maildirs on the server.

      Client mail processing is usually pretty unreliable. Makes me laugh when folks set up Outlook on their PCs to send vacation messages (yes, I know you can get Exchange to do it!) from their PCs... of course the cleaner needs that power-point, and so no vacation messages for three weeks, after the first evening 8-)

      What did you have in mind to do with your mail processing that is not covered already in the rules?

        The Application : User has added an exchange based SMS gateway emails -> sms, sms -> email

        Now wants to know if I could get a 2-way thing going upon receipt of email ? Hence perl ( DBI etc )

        I think the point of setting it up on the server is a good idea, I'll have a look.

        Regards
        Kevin
Re: Outlook - Custom Action
by mattr (Curate) on Nov 28, 2003 at 11:00 UTC
    This past month I built a little system that might be useful for your reference. I was thinking of doing a writeup since PM helped me to get a start on it.

    It continually connects to a mailbox with Net::POP3, scans the subject and sender, downloads email, and strips out and renames photos and text with MIME::Tools. Another perl process uses Win32::OLE to constantly update a MyAlbum slideshow to show the photos that people sent in from their camera-equipped phones.

    It keeps track of what was downloaded by saving the Unique ID hash provided by the server, so that you can also download email with Outlook and not lose your place. (You could download to Outlook and erase from the server though).

    If you have to look at headers the MIME Head object may be useful anyway also look at the Mail::Head.

    Anyway, if what you are really doing is an SMS gateway then Outlook is just going to give you big problems. How about making a separate account for the gateway, or using a procmail (if you are on unix)? By the way there is a bunch of Perl SMS stuff here.

    Of course if you only have one account you could download the mail to a local POP server running on your machine with fetchmail or this perl program, then retrieve non-SMS mail using Outlook from the local cache. Then you won't have to worry about email being deleted.

    By the way I would certainly like to hear how the SMS part is done since I may have to implement this art project in SMS early next year and there is no SMS in Japan where I live.

    Matt R.

Re: Outlook - Custom Action
by Wassercrats (Initiate) on Nov 27, 2003 at 11:55 UTC
    Aside from fairly well known security issues, Outlook stops working for mysterious reasons sometimes. Settings change, mail doesn't get delivered or received, etc. It's happened to me and I've confirmed that it's been a problem for others using Outlook Express. If possible, use a different email client, preferably one written in Perl.